@extends('admin.layouts.app')

@section('title', 'Penarikan Dana Pending')

@section('content')
<div class="bg-white shadow-md rounded-lg overflow-hidden">
    <div class="p-6">
        <h2 class="text-xl font-semibold text-gray-800 mb-4">Daftar Penarikan Dana Pending</h2>
        
        @if (session('success'))
            <div class="bg-green-100 border-l-4 border-green-500 text-green-700 p-4 mb-4" 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-4" role="alert">
                <p>{{ session('error') }}</p>
            </div>
        @endif
        
        @if(empty($withdrawals))
            <div class="text-center py-8">
                <svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
                </svg>
                <h3 class="mt-2 text-sm font-medium text-gray-900">Tidak ada penarikan dana pending</h3>
                <p class="mt-1 text-sm text-gray-500">Semua penarikan dana sudah diproses.</p>
            </div>
        @else
            <div class="overflow-x-auto">
                <table class="min-w-full bg-white">
                    <thead class="bg-gray-100">
                        <tr>
                            <th class="py-3 px-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th>
                            <th class="py-3 px-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nama Penjahit</th>
                            <th class="py-3 px-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Bank</th>
                            <th class="py-3 px-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">No. Rekening</th>
                            <th class="py-3 px-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Jumlah</th>
                            <th class="py-3 px-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
                            <th class="py-3 px-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Tanggal</th>
                            <th class="py-3 px-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Aksi</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-gray-200">
                        @foreach($withdrawals as $withdrawal)
                            <tr>
                                <td class="py-4 px-4 text-sm text-gray-900">{{ $withdrawal['id'] }}</td>
                                <td class="py-4 px-4 text-sm text-gray-900">{{ $withdrawal['wallet']['user']['name'] }}</td>
                                <td class="py-4 px-4 text-sm text-gray-900">{{ $withdrawal['bank_account']['bank_name'] }}</td>
                                <td class="py-4 px-4 text-sm text-gray-900">{{ $withdrawal['bank_account']['account_number'] }}</td>
                                <td class="py-4 px-4 text-sm text-gray-900">Rp {{ number_format($withdrawal['amount'], 0, ',', '.') }}</td>
                                <td class="py-4 px-4 text-sm">
                                    <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full 
                                        @if($withdrawal['status'] == 'pending') bg-yellow-100 text-yellow-800
                                        @elseif($withdrawal['status'] == 'completed') bg-green-100 text-green-800
                                        @elseif($withdrawal['status'] == 'rejected') bg-red-100 text-red-800
                                        @endif">
                                        {{ ucfirst($withdrawal['status']) }}
                                    </span>
                                </td>
                                <td class="py-4 px-4 text-sm text-gray-900">{{ \Carbon\Carbon::parse($withdrawal['created_at'])->format('d M Y') }}</td>
                                <td class="py-4 px-4 text-sm text-gray-900">
                                    @if($withdrawal['status'] == 'pending')
                                        <a href="{{ route('admin.withdrawals.show-process', $withdrawal['id']) }}" class="text-blue-600 hover:text-blue-900">Proses</a>
                                    @endif
                                </td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
        @endif
    </div>
</div>
@endsection 