@extends('layouts.app')

@section('page_title', 'Station Management')

@section('content')
    @if (session('error'))
        <div class="alert alert-danger">
            {{ session('error') }}
        </div>
    @endif

    <!-- Debug: Display raw stations data -->
    <div style="display: none;">
        <h6>Debug: Raw Stations Data</h6>
        <pre>{{ json_encode($stations, JSON_PRETTY_PRINT) }}</pre>
    </div>

    @include('components.station-component', [
        'pageTitle' => 'Station Management',
        'data' => $stations ?? [],
        'columns' => [
            ['name' => 'Station Code', 'key' => 'station_code', 'sortable' => true],
            ['name' => 'Station Name', 'key' => 'station_name', 'sortable' => true],
            ['name' => 'Branch Name', 'key' => 'branch_name', 'sortable' => true],
            ['name' => 'Date Created', 'key' => 'date_created', 'sortable' => true],
            ['name' => 'Created By', 'key' => 'created_by', 'sortable' => true],
            ['name' => 'Modified By', 'key' => 'modified_by', 'sortable' => true],
            ['name' => 'Date Modified', 'key' => 'date_modified', 'sortable' => true]
        ],
        'actions' => ['view', 'edit', 'delete'],
        'showAddButton' => true,
        'addButtonUrl' => route('stations.create'),
        'showCheckboxes' => false,
        'showBatchDelete' => false,
        'showEditModal' => true,
        'showViewModal' => true,
        'currentPage' => $currentPage ?? 1,
        'lastPage' => $lastPage ?? 1,
        'total' => $total ?? 0,
        'search' => $search ?? null,
    ])
    <div id="no-data-message" style="display: none; text-align: center; margin-top: 20px;">
        <p>No stations found.</p>
    </div>
@endsection