@extends('layouts.app')

@section('title', 'Data Admin - INUFA')

@section('header')
<div class="flex space-x-8">
    <a href="{{ route('pengguna') }}" class="font-semibold">Data User</a>
    <a href="{{ route('admin') }}" class="font-semibold border-b-2 border-white pb-1">Data Admin</a>
</div>
@endsection

@section('content')
<!-- Add Button -->
<div class="mb-6">
    <a href="{{ route('admin.create') }}" class="inline-block bg-white text-gray-800 px-4 py-2 rounded font-semibold">
        Tambah
    </a>
</div>

<!-- Table -->
<div class="bg-white rounded shadow overflow-x-auto">
    <table class="w-full table-fixed">
        <thead>
            <tr class="bg-gray-100">
                <th class="py-3 px-4 text-left w-12 border-r">No</th>
                <th class="py-3 px-4 text-left w-36 border-r">Username</th>
                <th class="py-3 px-4 text-left w-48 border-r">Email</th>
                <th class="py-3 px-4 text-left w-36 border-r">No.telp</th>
                <th class="py-3 px-4 text-left border-r">Alamat</th>
                <th class="py-3 px-4 text-center w-36">Aksi</th>
            </tr>
        </thead>
        <tbody>
            @forelse($admins as $index => $admin)
            <tr class="border-t">
                <td class="py-3 px-4 border-r">{{ $admin['id'] }}</td>
                <td class="py-3 px-4 border-r">{{ $admin['username'] }}</td>
                <td class="py-3 px-4 border-r">{{ $admin['email'] }}</td>
                <td class="py-3 px-4 border-r">{{ $admin['no_telp'] }}</td>
                <td class="py-3 px-4 border-r">{{ $admin['alamat'] }}</td>
                <td class="py-3 px-4 text-center">
                    <div class="flex justify-center space-x-2">
                        <a href="{{ route('admin.edit', $admin['id']) }}" class="inline-block bg-blue-600 text-white px-4 py-1 rounded-sm font-medium text-sm">
                            Edit
                        </a>
                        <form action="{{ route('admin.destroy', $admin['id']) }}" method="POST" class="inline">
                            @csrf
                            @method('DELETE')
                            <button type="submit" class="bg-red-500 text-white px-4 py-1 rounded-sm font-medium text-sm">
                                Hapus
                            </button>
                        </form>
                    </div>
                </td>
            </tr>
            @empty
            <tr class="border-t">
                <td colspan="6" class="py-3 px-4 text-center">Tidak ada data admin</td>
            </tr>
            @endforelse
        </tbody>
    </table>
</div>
@endsection 