@extends('layouts.app')
@section('title', 'Master Kecamatan')
@section('content')
    <div class="row">
        <div class="col-lg-12 d-flex align-items-stretch">
            <div class="card w-100">
                <div class="card-body p-4">
                    <div class="d-flex align-items-stretch">
                        <h5 class="card-title fw-semibold mb-4">Master Kecamatan</h5>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-responsive table-bordered text-nowrap mb-0 align-middle">
                            <thead class="text-dark fs-4">
                                <tr>
                                    <th class="border-bottom-0" width="65px">
                                        <h6 class="fw-semibold mb-0 text-center">#</h6>
                                    </th>
                                    <th class="border-bottom-0" style="max-width: 100px;">
                                        <h6 class="fw-semibold mb-0">Nama</h6>
                                    </th>
                                    <th class="border-bottom-0" style="max-width: 100px;">
                                        <h6 class="fw-semibold mb-0">Nama Provinsi</h6>
                                    </th>
                                    <th class="border-bottom-0" style="max-width: 100px;">
                                        <h6 class="fw-semibold text-center mb-0">Koordinat</h6>
                                    </th>
                                    <th class="border-bottom-0" style="width: 200px;">
                                        <h6 class="fw-semibold  text-center mb-0">Geo JSON</h6>
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                @forelse ($kecamatan as $_kecamatan)
                                    <tr>
                                        <td class="border-bottom-0 text-center">
                                            <span
                                                class="fw-normal mb-0">{{ ($kecamatan->currentPage() - 1) * $kecamatan->perPage() + $loop->index + 1 }}</span>
                                        </td>
                                        <td class="border-bottom-0" style="max-width: 100px;">
                                            <span class="fw-normal mb-1">{{ $_kecamatan->nama }}</span>
                                        </td>
                                        <td class="border-bottom-0" style="max-width: 100px;">
                                            <span class="fw-normal mb-1">{{ $_kecamatan->kabupaten->nama }}</span>
                                        </td>
                                        <td class="border-bottom-0 text-center" style="max-width: 100px;">
                                            <span
                                                class="fw-normal mb-1 badge text-bg-light">{{ $_kecamatan->coordinate }}</span>
                                        </td>
                                        <td class="border-bottom-0 text-center" style="width: 200px;">
                                            <span
                                                class="fw-normal mb-1 badge text-bg-light">{{ $_kecamatan->geojson ?? '-' }}</span>
                                        </td>
                                    </tr>
                                @empty
                                    <div class="alert alert-danger">
                                        Data master belum Tersedia.
                                    </div>
                                @endforelse
                            </tbody>
                        </table>
                        {{-- Pagination --}}
                        <div class="d-flex justify-content-center">
                            {!! $kecamatan->links('includes.custom-pagination') !!}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    @if (Session::has('kecamatans-message'))
        <script>
            Swal.fire({
                text: "{{ Session::get('kecamatans-message')['msg'] }}",
                icon: "{{ Session::get('kecamatans-message')['type'] }}",
                timer: 2500
            });
        </script>
    @endif
@stop
