@if(!defined('BASKET'))
    @push('scripts')
        <script>
            function initBasket(sel) {
                var selector = (typeof(sel) == 'undefined') ? '.basket' : sel;
            
                $(selector).off().click(function() {
                    var $addBasket = $(this).closest('.addBasket');
                    var offerId = $addBasket.find('.offer_id').val();
                    var quantity = $addBasket.find('.quantity').val();
                    var data = {
                        'offer_id': offerId,
                        'quantity': quantity,
                    };

                    console.log(data);

                    var buttons = {
                        cancel: {
                            label: '{{ __('Continuer mes achats') }}',
                            className: 'btn-secondary'
                        },
                        confirm: {
                            label: '{{ __('Commander') }}',
                            className: 'btn-success',
                            callback: function() {
                                window.location = "{{ route('Shop.Basket.basket') }}";
                            }
                        },
                    };

                    openModal(
                        'Ajout dans le panier',
                        'basket-form',
                        "{{ route('Shop.Basket.modalBasket') }}/" + offerId + '/' + quantity,
                        "{{ route('Shop.Orders.order') }}",
                        false,
                        false,
                        true,
                        buttons,
                        "refreshBasketTop()",
                    );
                });
            }
        </script>
    @endpush
    @php(define('BASKET', true))
@endif