
@extends('layouts.app')

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

@section('content')
    <div id="user-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.user-management-component', [
            'pageTitle' => 'User Management',
            'data' => $users,
            'columns' => [
                ['name' => 'Username', 'key' => 'username', 'sortable' => true],
                ['name' => 'First Name', 'key' => 'firstName', 'sortable' => true],
                ['name' => 'Last Name', 'key' => 'lastName', 'sortable' => true],
                ['name' => 'User Role', 'key' => 'role', 'sortable' => true],
                ['name' => 'Email', 'key' => 'email', 'sortable' => true],
                ['name' => 'Status', 'key' => 'status', 'sortable' => true],
            ],
            'actions' => ['view', 'edit', 'delete'],
            'showAddButton' => true,
            'addButtonUrl' => route('user-management.create'),
            'showCheckboxes' => true,
            'showBatchDelete' => true,
            'showEditModal' => false,
            'showViewModal' => false,
        ])
        <div id="no-data-message" style="display: {{ empty($users) ? 'block' : 'none' }}; text-align: center; margin-top: 20px;">
            <p>No users found.</p>
        </div>
    </div>
@endsection
