@extends('layouts.admin')
@section('content')
<div class="page-header">
    <div class="page-block">
        <div class="row align-items-center">
            <div class="col-md-12">
                <ul class="breadcrumb">
                    <li class="breadcrumb-item"><a href="{{ route('admin.dashboard') }}">হোম</a></li>
                    <li class="breadcrumb-item"><a href="javascript: void(0)">সংগঠন</a></li>
                    <li class="breadcrumb-item" aria-current="page">Districts</li>
                </ul>
            </div>
            <div class="col-md-12">
                <div class="page-header-title">
                    <h2 class="mb-0">{{ __('Districts') }}</h2>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row mb-3">
    <div class="col-lg-12 text-end">
        <a class="btn btn-primary text-white" href="{{ route('district.create') }}">
            <i class="ti ti-plus me-1"></i> {{ __('Add New District') }}
        </a>
    </div>
</div>

<div class="card tbl-card">
    <div class="card-header"><h5>{{ __('Districts List') }}</h5></div>
    <div class="card-body">
        @include('includes.admin.form-success')
        <div class="table-responsive">
            <table class="table table-hover table-borderless mb-0">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>{{ __('Division') }}</th>
                        <th>{{ __('Name') }}</th>
                        <th>{{ __('Actions') }}</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($districts as $key => $district)
                    <tr>
                        <td>{{ $key + 1 }}</td>
                        <td>{{ $district->division->name ?? 'N/A' }}</td>
                        <td>{{ $district->name }}</td>
                        <td>
                            <a href="{{ route('district.edit', $district->id) }}" class="btn btn-sm btn-light-primary"><i class="ti ti-edit"></i></a>
                            <form action="{{ route('district.destroy', $district->id) }}" method="POST" style="display:inline;" onsubmit="return confirm('Are you sure?')">
                                @csrf @method('DELETE')
                                <button type="submit" class="btn btn-sm btn-light-danger"><i class="ti ti-trash"></i></button>
                            </form>
                        </td>
                    </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    </div>
</div>
@endsection
