@extends('layouts.admin', ['heading' => 'Member Imports', 'subheading' => 'Bulk import history'])

@section('content')
    <div class="admin-card p-5">
        <div class="overflow-x-auto">
            <table class="min-w-full text-sm">
                <thead class="bg-slate-100 text-left">
                    <tr>
                        <th class="p-3">Batch</th>
                        <th class="p-3">Status</th>
                        <th class="p-3">Processed</th>
                        <th class="p-3">Failed</th>
                        <th class="p-3">Error Report</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($imports as $batch)
                        <tr class="border-t">
                            <td class="p-3">#{{ $batch->id }}</td>
                            <td class="p-3">{{ $batch->status }}</td>
                            <td class="p-3">{{ $batch->processed_rows }}/{{ $batch->total_rows }}</td>
                            <td class="p-3">{{ $batch->failed_rows }}</td>
                            <td class="p-3">
                                @if($batch->error_report_path)
                                    <a href="{{ route('admin.members.imports.errors', $batch) }}" class="text-xs text-emerald-700 underline">Download</a>
                                    <div class="text-xs text-slate-500">{{ $batch->error_report_path }}</div>
                                @else
                                    <span class="text-xs text-slate-400">None</span>
                                @endif
                            </td>
                        </tr>
                    @empty
                        <tr><td colspan="5" class="p-4 text-center text-slate-500">No imports yet.</td></tr>
                    @endforelse
                </tbody>
            </table>
        </div>
        <div class="mt-4">{{ $imports->links() }}</div>
    </div>
@endsection
