@extends('admin.layouts.app')

@section('title', 'Akun Bank Terverifikasi | TailorHub Admin')

@section('content')
<div class="container px-6 mx-auto grid">
    <h2 class="my-6 text-2xl font-semibold text-gray-700">
        Akun Bank Terverifikasi
    </h2>

    <!-- Filter & Search -->
    <div class="mb-6 bg-white rounded-lg shadow-md p-4">
        <form action="{{ route('admin.bank-accounts.verified') }}" method="GET" class="flex flex-col md:flex-row gap-4">
            <div class="flex-1">
                <label for="status" class="block text-sm font-medium text-gray-700 mb-1">Status</label>
                <select id="status" name="status" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-blue-500 focus:border-blue-500">
                    <option value="">Semua Status</option>
                    <option value="active" {{ request('status') == 'active' ? 'selected' : '' }}>Diterima</option>
                    <option value="rejected" {{ request('status') == 'rejected' ? 'selected' : '' }}>Ditolak</option>
                </select>
            </div>
            <div class="flex-1">
                <label for="search" class="block text-sm font-medium text-gray-700 mb-1">Cari</label>
                <input type="text" id="search" name="search" value="{{ request('search') }}" placeholder="Cari nama penjahit, bank, nomor rekening..." class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-blue-500 focus:border-blue-500">
            </div>
            <div class="flex items-end">
                <button type="submit" class="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
                    Filter
                </button>
            </div>
        </form>
    </div>

    <!-- Alert Status -->
    @if (session('success'))
    <div class="bg-green-100 border-l-4 border-green-500 text-green-700 p-4 mb-6 rounded" role="alert">
        <p>{{ session('success') }}</p>
    </div>
    @endif

    @if (session('error'))
    <div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded" role="alert">
        <p>{{ session('error') }}</p>
    </div>
    @endif

    <!-- Tabel Data -->
    <div class="bg-white rounded-lg shadow-md overflow-hidden">
        <table class="w-full whitespace-no-wrap">
            <thead>
                <tr class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b bg-gray-50">
                    <th class="px-4 py-3">ID</th>
                    <th class="px-4 py-3">Penjahit</th>
                    <th class="px-4 py-3">Bank</th>
                    <th class="px-4 py-3">Nomor Rekening</th>
                    <th class="px-4 py-3">Nama Pemilik</th>
                    <th class="px-4 py-3">Status</th>
                    <th class="px-4 py-3">Waktu Verifikasi</th>
                    <th class="px-4 py-3">Aksi</th>
                </tr>
            </thead>
            <tbody class="bg-white divide-y">
                @forelse ($bankAccounts as $account)
                <tr class="text-gray-700">
                    <td class="px-4 py-3 text-sm">
                        {{ $account['id'] }}
                    </td>
                    <td class="px-4 py-3">
                        <div class="flex items-center text-sm">
                            <div>
                                <p class="font-semibold">{{ $account['user']['name'] }}</p>
                                <p class="text-xs text-gray-600">{{ $account['user']['email'] }}</p>
                            </div>
                        </div>
                    </td>
                    <td class="px-4 py-3 text-sm">
                        {{ $account['bank_name'] }}
                    </td>
                    <td class="px-4 py-3 text-sm">
                        {{ $account['account_number'] }}
                    </td>
                    <td class="px-4 py-3 text-sm">
                        {{ $account['account_holder_name'] }}
                    </td>
                    <td class="px-4 py-3 text-sm">
                        @if ($account['status'] == 'active')
                        <span class="px-2 py-1 font-semibold leading-tight text-green-700 bg-green-100 rounded-full">
                            Diterima
                        </span>
                        @elseif ($account['status'] == 'rejected')
                        <span class="px-2 py-1 font-semibold leading-tight text-red-700 bg-red-100 rounded-full" title="{{ $account['rejection_reason'] }}">
                            Ditolak
                        </span>
                        @else
                        <span class="px-2 py-1 font-semibold leading-tight text-gray-700 bg-gray-100 rounded-full">
                            {{ $account['status'] }}
                        </span>
                        @endif
                    </td>
                    <td class="px-4 py-3 text-sm">
                        {{ \Carbon\Carbon::parse($account['verified_at'])->format('d M Y H:i') }}
                    </td>
                    <td class="px-4 py-3 text-sm">
                        <a href="{{ route('admin.bank-accounts.detail', $account['id']) }}" class="text-blue-600 hover:underline">Detail</a>
                    </td>
                </tr>
                @empty
                <tr class="text-gray-700">
                    <td colspan="8" class="px-4 py-3 text-sm text-center">
                        Tidak ada data akun bank yang terverifikasi.
                    </td>
                </tr>
                @endforelse
            </tbody>
        </table>
    </div>
</div>
@endsection 