@extends('Shop.layout.layout', [
    'title' => __('Commande'),
])

@section('content')
    <div class="row">
        <div class="@if ($basket['count']) col-8 @else col-12 @endif">
            @if (App\Repositories\Shop\Customers::isNotConnected())
                <p>
                    <a href="#" id="customer" class="pr-5">Déja client ?</a>
                    <button class="btn btn-secondary" id="register">Créez mon compte</button>
                </p>

                <x-layout.collapse id="identification" title="Déjà client" class="identification rounded-lg" uncollapsed=true>
                    @include('Shop.auth.partials.login')
                </x-layout.collapse>

                <x-layout.collapse id="personal_data" title="Informations personnelles"
                    class="d-none personal_data rounded-lg" uncollapsed=true>
                    @include('Shop.auth.partials.register')
                </x-layout.collapse>
            @else
                {{ Form::open(['route' => 'Shop.Orders.store', 'id' => 'order-form', 'autocomplete' => 'off']) }}
                @include('Shop.Orders.partials.registered')
                {!! Form::close() !!}
            @endif

        </div>
        @if ($basket['count'])
            <div class="col-4">
                <x-card class='shadow'>
                    @include('Shop.Baskets.partials.basketTotal')
                </x-card>
            </div>
        @endif
    </div>
@endsection

@include('load.layout.chevron')

@push('js')
    <script>
        $('#customer').click(function() {
            $(".personal_data").addClass('d-none');
            $('.identification').removeClass('d-none');
            $('#identification').collapse('show');
        });

        $('#register').click(function() {
            $('.identification').addClass('d-none');
            $(".personal_data").removeClass('d-none');
            $('#personal_data').collapse('show');
        });

        $('#delivery_mode .delivery_mode').click(function() {
            var test = $(this).hasClass('at_house');
            if ($(this).hasClass('at_house')) {
                $('#delivery_addresses').closest('.card').removeClass('d-none');
            } else {
                $('#delivery_addresses').closest('.card').addClass('d-none');
            }
        });

        initChevron();
    </script>
@endpush
