@extends('layouts.app')

@section('page_title', 'Card Types')

@section('content')
    <div id="card-types-table">
        @if (session('success'))
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                {{ session('success') }}
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
        @endif
        @if (session('error'))
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                {{ session('error') }}
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
        @endif
        @include('components.card-type-component', [
            'pageTitle' => 'Card Types',
            'data' => $cardTypes ?? [],
            'columns' => [
                ['name' => 'Card Type Code', 'key' => 'cardCode', 'sortable' => true],
                ['name' => 'Type', 'key' => 'type', 'sortable' => true],
                ['name' => 'Card Type Description', 'key' => 'cardTypeDescription', 'sortable' => true],
            ],
            'allFields' => [
                ['name' => 'Card Code', 'key' => 'code', 'type' => 'text', 'required' => true],
                ['name' => 'Type', 'key' => 'type', 'type' => 'select', 'options' => ['Visa', 'MasterCard', 'Amex'], 'required' => true],
                ['name' => 'Card Type Description', 'key' => 'description', 'type' => 'text', 'required' => true],
                ['name' => 'Card Type Short Description', 'key' => 'short_description', 'type' => 'text', 'required' => true],
                ['name' => 'Card Type Image', 'key' => 'image', 'type' => 'file'],
                ['name' => 'Virtual Card Font Color', 'key' => 'virtual_card_font_color', 'type' => 'select', 'options' => ['White', 'Black'], 'required' => true],
                ['name' => 'Card Type Cover Image', 'key' => 'bg_image', 'type' => 'file'],
                ['name' => 'ID Number Required?', 'key' => 'id_number', 'type' => 'select', 'options' => ['Yes', 'No'], 'required' => true],
                ['name' => 'ID Number Description', 'key' => 'id_number_description', 'type' => 'text'],
                ['name' => 'Terms and Conditions', 'key' => 'terms_and_conditions', 'type' => 'textarea', 'required' => true],
                ['name' => 'FAQs', 'key' => 'faqs', 'type' => 'textarea', 'required' => true],
            ],
            'actions' => ['edit', 'view', 'delete'],
            'showAddButton' => true,
            'addButtonUrl' => route('card-types.create'),
            'showCheckboxes' => true,
            'showBatchDelete' => true,
            'showEditModal' => true,
            'showViewModal' => true,
            'currentPage' => $currentPage ?? 1,
            'lastPage' => $lastPage ?? 1,
            'total' => $total ?? 0,
        ])
        <div id="no-data-message" style="display: {{ empty($cardTypes ?? []) ? 'block' : 'none' }}; text-align: center; margin-top: 20px;">
            <p>No card types found.</p>
        </div>
    </div>
@endsection