Email Triage {{-- ── TAB BAR ─────────────────────────────────────────────────────────── --}}
@php $tabs = [ 'dsar_evidence' => ['label' => 'DSAR Evidence', 'icon' => 'mdi-file-check-outline', 'color' => 'success'], 'dsar_updates' => ['label' => 'Updates', 'icon' => 'mdi-email-sync-outline', 'color' => 'info'], 'dsar_needs_research' => ['label' => 'Needs Research', 'icon' => 'mdi-magnify-scan', 'color' => 'warning'], 'unknown' => ['label' => 'Unknown', 'icon' => 'mdi-help-circle-outline', 'color' => 'secondary'], ]; @endphp @foreach($tabs as $key => $cfg) @php $cnt = $counts[$key] ?? 0; @endphp @endforeach
{{-- ── MAIN SPLIT PANE ─────────────────────────────────────────────────── --}}
{{-- ── LEFT: message list ──────────────────────────────────────── --}}
@if($messages->isEmpty())
All clear — nothing to triage here.
@else
@foreach($messages as $msg) @php $isPending = $msg->triage_status === 'pending'; $isInProgress = $msg->triage_status === 'in_progress'; $isActioned = $msg->triage_status === 'actioned'; $isDismissed = $msg->triage_status === 'dismissed'; $isActive = $messageId === $msg->id; @endphp @endforeach
@if($messages->hasPages())
{{ $messages->links() }}
@endif @endif
{{-- ── RIGHT: message detail ───────────────────────────────────── --}}
@if($openMessage) {{-- Header --}}
{{-- ── Message meta ── --}}
{{ $openMessage->subject ?: '(no subject)' }}
From: {{ $openMessage->from_email }} • {{ $openMessage->created_at->format('d M Y, H:i') }} {{-- Synapse classification inline --}} Synapse @if($openMessage->classification_confidence) {{ ucfirst($openMessage->classification_confidence) }} confidence @endif @if($openMessage->messageable_type && str_contains($openMessage->messageable_type, 'Dsar') && $openMessage->messageable) @php $dsar = $openMessage->messageable; @endphp DSAR{{ $dsar->reference ? ': ' . $dsar->reference : ' #' . $dsar->id }} @endif @if($openMessage->classification_notes) {{ $openMessage->classification_notes }} @endif
{{-- ── Action toolbar ── --}}
{{-- Navigate --}} @if(($tab === 'dsar_evidence' || $tab === 'dsar_needs_research') && $openMessage->messageable_type && str_contains($openMessage->messageable_type, 'Dsar') && $openMessage->messageable) Open DSAR @endif {{-- Reply --}}
{{-- Workflow --}} @if(in_array($openMessage->triage_status, ['pending', 'in_progress'])) @else {{ ucfirst($openMessage->triage_status) }} @endif @if($tab === 'dsar_needs_research') @endif
{{-- Synapse --}}
{{-- Link-to-DSAR panel (unknown tab only) --}} @if($tab === 'unknown')
Link to a DSAR
@if(count($dsarResults) > 0)
@foreach($dsarResults as $dsar) @php $client = $dsar->claim?->client; $label = trim(($client?->name_first ?? '') . ' ' . ($client?->name_last ?? '')); @endphp
{{ $dsar->reference ?: 'DSAR #' . $dsar->id }} @if($label) {{ $label }} @endif @if($dsar->institution) — {{ $dsar->institution->name }} @endif {{ $dsar->status }}
@endforeach
@elseif(strlen($dsarSearch) >= 2)

No open DSARs found matching "{{ $dsarSearch }}".

@endif
@endif {{-- Scrollable body + attachments --}}
@if($openMessage->body_html) @elseif($openMessage->body_text)
{{ $openMessage->body_text }}
@else

This email has no body content.

@endif
@if($openMessage->attachments->isNotEmpty())
Attachments ({{ $openMessage->attachments->count() }})
@foreach($openMessage->attachments as $attachment) @php $exStatus = $attachment->extraction_status; $mime = $attachment->mime ?? ''; $fname = strtolower($attachment->filename ?? ''); $isImage = str_starts_with($mime, 'image/') || (bool) preg_match('/\.(jpg|jpeg|png|gif|webp|bmp|svg)$/', $fname); $isPdf = str_contains($mime, 'pdf') || str_ends_with($fname, '.pdf'); $isText = str_starts_with($mime, 'text/'); $previewable = $isImage || $isPdf || $isText; // Only offer a manual note for non-previewable attachments that have no text $needsNote = !$previewable && in_array($exStatus, ['skipped', 'failed', null]); @endphp
{{ $attachment->filename }} @if($attachment->size) ({{ number_format($attachment->size / 1024, 1) }} KB) @endif
@if($previewable) @endif
@if($exStatus === 'completed') @elseif($exStatus === 'manual') @elseif(!$previewable && ($exStatus === 'skipped' || is_null($exStatus))) Not readable @endif
{{-- Extracted text --}} @if($exStatus === 'completed' && !empty($attachment->extracted_text))
{{ $attachment->extracted_text }}
@endif {{-- Manual note --}} @if($needsNote || $exStatus === 'manual') @if($needsNote)
@endif
@if($needsNote)

Describe what this attachment contains — Synapse will use this when re-classifying.

@endif
@endif
@endforeach
@endif
{{-- /scrollable body --}} @else

Select an email to review it

@endif
{{-- ── ATTACHMENT PREVIEW MODAL ──────────────────────────────────── --}}