<div class="row">
    <div class="col-6">
        {{ Form::open(['route' => 'Admin.Shop.Customers.store', 'id' => 'customer-form', 'autocomplete' => 'off']) }}
        <input type="hidden" name="id" value="{{ $customer['id'] ?? false }}">
        <x-card>
            <div class="row mb-3">
                <div class="col-6">
                    @include('components.form.input', [
                        'name' => 'first_name',
                        'value' => $customer['first_name'] ?? null,
                        'required' => true,
                        'label' => 'Prénom',
                    ])
                </div>
                <div class="col-6">
                    @include('components.form.input', [
                        'name' => 'last_name',
                        'value' => $customer['last_name'] ?? null,
                        'required' => true,
                        'label' => 'Nom',
                    ])
                </div>
            </div>
            <div class="row mb-3">
                <div class="col-12">
                    @include('components.form.input', [
                        'name' => 'company',
                        'value' => $customer['company'] ?? null,
                        'label' => 'Société',
                    ])
                </div>
            </div>
            <div class="row mb-3">
                <div class="col-12">
                    @include('components.form.input', [
                        'name' => 'tva',
                        'value' => $customer['tva'] ?? null,
                        'label' => 'TVA',
                    ])
                </div>
            </div>
            <div class="row mb-3">
                <div class="col-6">
                    @include('components.form.input', [
                        'name' => 'email',
                        'value' => $customer['email'] ?? null,
                        'required' => true,
                        'label' => 'Email',
                    ])
                </div>
                <div class="col-6">
                    @include('components.form.input', [
                        'name' => 'phone',
                        'value' => $customer['phone'] ?? null,
                        'label' => 'Téléphone',
                    ])
                </div>
            </div>

            <div class="row mb-3">
                <div class="col-12">
                    @include('components.form.input', [
                        'name' => 'address',
                        'value' => $customer['address'] ?? null,
                        'required' => true,
                        'label' => 'Adresse',
                    ])
                </div>
            </div>

            <div class="row mb-3">
                <div class="col-12">
                    @include('components.form.input', [
                        'name' => 'address2',
                        'value' => $customer['address2'] ?? null,
                        'label' => 'Adresse complémentaire',
                    ])
                </div>
            </div>

            <div class="row mb-3">
                <div class="col-4">
                    @include('components.form.input', [
                        'name' => 'zipcode',
                        'value' => $customer['zipcode'] ?? null,
                        'required' => true,
                        'label' => 'Code postal',
                    ])
                </div>
                <div class="col-8">
                    @include('components.form.input', [
                        'name' => 'city',
                        'value' => $customer['city'] ?? null,
                        'required' => true,
                        'label' => 'Ville',
                    ])
                </div>
            </div>

            <div class="row mb-3">
                <div class="col-12">
                    @include('components.form.select', [
                        'name' => 'sale_channels[]',
                        'list' => $sale_channels ?? [],
                        'values' => $customer['sale_channels'] ?? null,
                        'with_empty' => '',
                        'class' => 'select2',
                        'multiple' => true,
                        'label' => __('shop.sale_channels.name'),
                    ])
                </div>
            </div>
        </x-card>
    </div>
    </form>
    <div class="col-6">
        <x-layout.box-collapse title='Adresses' id='customer-addresses'>
            @include('Admin.Shop.CustomerAddresses.list', ['dataTable' => $customer_addresses])
        </x-layout.box-collapse>
        <x-layout.box-collapse title='Factures' id='customer-invoices'>
            @include('Admin.Shop.CustomerInvoices.list', ['dataTable' => $customer_invoices])
        </x-layout.box-collapse>
        <x-layout.box-collapse title='Commandes' id='customer-orders'>
            @include('Admin.Shop.CustomerOrders.list', ['dataTable' => $customer_orders])
        </x-layout.box-collapse>
    </div>
</div>

<x-save />

@include('load.form.save')
@include('load.form.select2')
@include('load.layout.chevron')

@push('js')
    {!! JsValidator::formRequest('App\Http\Requests\Admin\Shop\StoreCustomerPost', '#customer-form') !!}

    <script>
        $(function() {
            initChevron();
            initSelect2();
            initSaveForm('#customer-form');
        });
    </script>
@endpush
