<x-app-layout>
    @section('title')
        Pages Management
    @endsection
    <!-- Page Heading -->
    {{-- <h1 class="h3 mb-2 text-gray-800">
        @can('Page create')
            <a href="{{ route('admin.pages.create') }}" class="btn btn-primary"><i
                    class="fas fa-plus" aria-hidden="true"></i>
                Add New company image
            </a>
        @endcan
    </h1> --}}
    <!-- DataTales Example -->
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary">
                Create
            </h6>
        </div>
        <div class="card-body">
            <form action="{{ route('admin.partnerrules.store') }}" method="POST">
                @csrf
                <div class="row">
                    <div class="col-12">
                        <label for="">Title</label>
                        <textarea name="title"  class="form-control summernote"></textarea>

                    </div>
                    <div class="col-12">
                        <label for="">Description</label>
                        <textarea name="description" placeholder="Description" class="form-control summernote"></textarea>
                    </div>

                    <div class="col-12">
                        <label for="">Rule</label>
                        <div id="rulesContainer">
                            <div class="rule-input-container d-flex">
                                <input type="text" class="form-control rule-input" name="rules[]" placeholder="Rule">
                                <button type="button" class="btn btn-danger delete-rule">Delete</button>
                                <button type="button" class="btn btn-secondary add-rule">Add More</button>
                            </div>
                        </div>
                    </div>
                    <div class="col-12">
                        <div class="mt-3">
                            <button type="submit" class="btn btn-primary">Submit</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <script>
        $(document).ready(function () {
            $(document).on('click', '.add-rule', function () {
                $(this).closest('.rule-input-container').after('<div class="rule-input-container"><input type="text" class="form-control rule-input" name="rules[]" placeholder="Rule"><button type="button" class="btn btn-danger delete-rule">Delete</button>  </div>');
            });

            $(document).on('click', '.delete-rule', function () {
                $(this).closest('.rule-input-container').remove();
            });
        });
    </script>
</x-app-layout>
