@extends('super-admin.layout')

@section('title', 'Notification log')

@section('content')
<div class="pg-head">
    <div>
        <h1>Notification log</h1>
    </div>
    <a href="{{ route('mexco.super.notifications') }}" class="btn-outline">← Templates</a>
</div>

<div class="card section-card" style="margin-bottom:1rem">
    <form method="GET">
        <select name="status" class="form-input" style="max-width:160px" onchange="this.form.submit()">
            <option value="">All statuses</option>
            @foreach(['logged','sent','failed'] as $s)
                <option value="{{ $s }}" @selected($status === $s)>{{ ucfirst($s) }}</option>
            @endforeach
        </select>
    </form>
</div>

<div class="card">
    <div class="tbl-wrap">
        <table class="data-tbl">
            <thead>
                <tr>
                    <th>When</th>
                    <th>Template</th>
                    <th>Recipient</th>
                    <th>Subject</th>
                    <th>Status</th>
                </tr>
            </thead>
            <tbody>
                @forelse($logs as $log)
                    <tr>
                        <td class="cell-sub">{{ $log->created_at->format('d M Y, H:i') }}</td>
                        <td class="mono">{{ $log->template_code }}</td>
                        <td>{{ $log->recipient }}</td>
                        <td class="cell-sub">{{ $log->subject }}</td>
                        <td>{{ ucfirst($log->status) }}</td>
                    </tr>
                @empty
                    <tr><td colspan="5" class="text-center cell-sub py-4">No log entries.</td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
    @if($logs->hasPages())
        <div style="padding:1rem">{{ $logs->withQueryString()->links() }}</div>
    @endif
</div>
@endsection
