@extends('layouts.app')

@section('page_title', 'Top-Up')

@section('content')
    <div id="topup-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.top-up-component', [
            'pageTitle' => 'Top-Up',
            'data' => $topups,
            'columns' => [
                ['name' => 'Free Code', 'key' => 'freeCode', 'sortable' => true],
                ['name' => 'Name', 'key' => 'name', 'sortable' => true],
                ['name' => 'Value', 'key' => 'value', 'sortable' => true],
                ['name' => 'Type', 'key' => 'type', 'sortable' => true],
            ],
            'actions' => ['view', 'edit', 'delete'],
            'showAddButton' => true,
            'addButtonUrl' => route('top-up.create'),
            'showCheckboxes' => true,
            'showBatchDelete' => true,
            'currentPage' => $currentPage ?? 1,
            'lastPage' => $lastPage ?? 1,
            'total' => $total ?? 0,
        ])
        <div id="no-data-message" style="display: {{ empty($topups) ? 'block' : 'none' }}; text-align: center; margin-top: 20px;">
            <p>No top-ups found.</p>
        </div>
    </div>
@endsection