@extends('layouts.app')

@section('content')

    <div class="row mb-3">
        <div class="col-6">
            <h3>Ответственные</h3>
        </div>
        <div class="col-6 text-end">
            <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addModal">
                Добавить
            </button>

        </div>
    </div>


    @include('partials.table', [
        'id'        => $id,
        'header'    => $header,
        'strings'   => $responsibles,
        'routeName' => 'responsible.show',
    ])

    <div class="row pt-3 px-3">
        <div class="col-12 pagination">
            {{ $responsibles->links() }}
        </div>
    </div>

    <!-- Модальное окно добавления-->
    <div class="modal fade" id="addModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-fullscreen-sm-down modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h1 class="modal-title fs-5" id="addModalLabel">Добавить заказ МАФ</h1>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
                </div>
                <div class="modal-body">
                    <form action="{{ route('responsible.store') }}" method="post">
                        @csrf

                        @include('partials.select', ['name' => 'area_id', 'title' => 'Район', 'options' => $areas])
                        @include('partials.input', ['name' => 'name', 'title' => 'ФИО', 'required' => true])
                        @include('partials.input', ['name' => 'phone', 'title' => 'Телефон', 'required' => true])

                        @include('partials.submit', ['name' => 'Добавить'])

                    </form>
                </div>
            </div>
        </div>
    </div>

    @if($errors->count())
        @dump($errors)
    @endif
@endsection


@push('scripts')
{{--    <script type="module">--}}
{{--        $('#select_maf').on('change', function () {--}}
{{--            $('#product_id').val($(this).val());--}}
{{--            $('#product_name').val($('#select_maf option:selected').text()).slideDown();--}}
{{--            $('#select_maf_form').slideUp();--}}
{{--            $('#sku_form').slideDown();--}}


{{--        });--}}
{{--    </script>--}}
@endpush
