<div>
{{-- Top Nav --}}
@include('livewire.promotion.top-nav.promotion')

@if (session()->has('success'))
    <div
        x-data="{ show: true }"
        x-init="setTimeout(() => show = false, 3000)"
        x-show="show"
        x-transition
        class="text-2xl text-green-700 px-4 py-2 rounded mb-4">
        ✅ {{ session('success') }}
    </div>
@endif


<livewire:components.table 
    :columns="[
        ['label' => 'Title', 'field' => 'title', 'type' => 'text'],
        ['label' => 'Type', 'field' => 'type', 'type' => 'select', 'options' => [
                                                                1 => 'General',
                                                                2 => 'Loyalty Exclusive',
                                                                3 => 'User Specific'
                                                    ]],
        ['label' => 'Start Date', 'field' => 'date_start', 'type' => 'date'],
        ['label' => 'End Date', 'field' => 'date_end', 'type' => 'date'],
        ['label' => 'Status', 'field' => 'status', 'type' => 'text'],
    ]"
    :rows="$promotions" 
    :hasCheckbox="true"
    :hasActions="true"
    :isViewPage="false"
    :addRoute="route('promotion-create')" 
    :rowKey="'promotion_uuid'"
    :updateRoute="'/main/promotion/promotion-update'"
    :viewRoute="'/main/promotion/promotion-view'"
    :deleteEndpoint="'api/cms/promotion'"
    :deleteAllEndpoint="'api/cms/promotionBatchDelete'"
    />
</div>
