@if ($delivery_types ?? false)
    <table class="">
        <thead>
            <tr>
                <th colspan="3">
                    Choix du transporteur
                </th>
            </tr>
        </thead>
        @foreach ($delivery_types as $delivery_type_id => $delivery_type)
            <tr>
                <td>
                    @include('components.form.radios.icheck', [
                        'name' => 'delivery_type_id',
                        'val' => $delivery_type_id,
                        'id' => 'delivery_type_' . $delivery_type_id,
                        'class' => 'delivery_type',
                    ])
                </td>
                <td>
                    {{ $delivery_type['name'] }}
                </td>
                <td class="text-right">
                    {{ $delivery_type['price'] }} €
                </td>
            </tr>
        @endforeach
    </table>
@endif

@push('js')
    <script>
        function handleDeliveryTypes() {
            $('input.delivery_type').change(function() {
                var deliveryTypeId = $(this).val();
                var deliveryId = $('input[name=delivery_id]:checked').val()
                refreshBasketTotal(deliveryId, deliveryTypeId);
            });
        }
        handleDeliveryTypes();
    </script>
@endpush
