Email Triage {{-- ── TAB BAR ─────────────────────────────────────────────────────────── --}}
@php $tabs = [ 'dsar_evidence' => ['label' => 'DSAR Evidence', 'icon' => 'mdi-file-check-outline', 'color' => 'success'], 'dsar_updates' => ['label' => 'Acknowledgements/Auto-Replies', 'icon' => 'mdi-email-sync-outline', 'color' => 'info'], 'dsar_needs_research' => ['label' => 'Pushback/Wrong Information', 'icon' => 'mdi-magnify-scan', 'color' => 'warning'], 'portal_response' => ['label' => 'Portal Responses', 'icon' => 'mdi-link-box-outline', '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 {{-- ── Toolbar (right side of tab row) ── --}}
{{-- 3-state view mode toggle --}}
{{-- Handler override dropdown --}} @can('inbox.override_handler')
@endcan
{{-- ── OVERRIDE BANNER ─────────────────────────────────────────────────── --}} @if($overrideHandlerId) @php $overrideUser = $availableHandlers->firstWhere('id', $overrideHandlerId); @endphp @if($overrideUser)
Viewing {{ $overrideUser->name_first }} {{ $overrideUser->name_last }}'s queue
@endif @endif {{-- ── MAIN CONTENT ────────────────────────────────────────────────────── --}}
@if($currentMessage) {{-- ── EMAIL HEADER + ACTIONS ─────────────────────────────────── --}} @php $isMatched = $currentMessage->messageable_type && str_contains($currentMessage->messageable_type, 'Dsar'); $dsarLinked = $isMatched && $currentMessage->messageable instanceof \App\Models\Dsar\Dsar ? $currentMessage->messageable : null; @endphp
{{-- ── Match status strip ── --}} @if($dsarLinked)
Matched {{ $dsarLinked->reference ?? 'DSAR #' . $dsarLinked->id }} @if($dsarLinked->claim?->client) @php $linkedClient = $dsarLinked->claim->client; @endphp · {{ $linkedClient->name_first }} {{ $linkedClient->name_last }} @endif @if($dsarLinked->institution) — {{ $dsarLinked->institution->display_name }} @endif
@can('dsars.batch.send') @php $currentStatus = $dsarLinked->status; $settableStatuses = \App\Enum\Dsar\DsarStatus::triageSelectable(); @endphp @endcan
@else
Unmatched Search in the left panel to link this email to a DSAR
@endif {{-- ── Subject + meta + actions ── --}}
{{ $currentMessage->subject ?: '(no subject)' }}
{{ $currentMessage->from_email }} {{ $currentMessage->created_at->format('d M Y, H:i') }}
{{-- Action buttons --}}
@if($dsarLinked) Open DSAR @endif
{{-- Manual reclassify dropdown --}} @php $queueLabels = [ 'dsar_evidence' => 'DSAR Evidence', 'dsar_updates' => 'Acknowledgements / Auto-Replies', 'dsar_needs_research' => 'Pushback / Wrong Information', 'portal_response' => 'Portal Responses', 'unknown' => 'Unknown', ]; @endphp
@foreach($queueLabels as $queueKey => $queueName) @if($queueKey !== $tab) @endif @endforeach
{{-- ── SPLIT PANELS ────────────────────────────────────────────── --}}
{{-- LEFT: Thread / Email body panel --}}
{{-- Panel header --}}
@if($isMatched)Thread @else Email @endif
{{-- Panel content --}}
@if($isMatched && !$relinking) {{-- DSAR Thread timeline --}}
@foreach($thread as $msg) @php $isInbound = $msg->direction->value === 'inbound'; $isCurrent = $msg->id === $currentMessage->id; $dirBg = $isInbound ? '#eff6ff' : '#f9fafb'; $dirBorder = $isInbound ? '#bfdbfe' : '#e5e7eb'; $dirColor = $isInbound ? '#2563eb' : '#6b7280'; $dirLabel = $isInbound ? 'Inbound' : 'Outbound'; $dirIcon = $isInbound ? 'mdi-email-arrow-left-outline' : 'mdi-email-arrow-right-outline'; @endphp
{{-- Message row (always visible) --}} {{-- Message body (expandable) --}}
@if($msg->body_html) @elseif($msg->body_text)
{{ $msg->body_text }}
@else

No body content.

@endif
@endforeach
@else {{-- Unmatched or re-linking: DSAR search at top --}}
{{-- DSAR link/relink search — pinned at top --}}
@if($relinking) Change DSAR @else Link to a DSAR @endif
@if($dsarResults->isNotEmpty())
@foreach($dsarResults as $dsar) @php $client = $dsar->claim?->client; $label = trim(($client?->name_first ?? '') . ' ' . ($client?->name_last ?? '')); @endphp
{{ $dsar->reference ?: 'DSAR #' . $dsar->id }} @if($dsar->receiver_reference) · their ref {{ $dsar->receiver_reference }} @endif @if($label) {{ $label }} @endif @if($dsar->institution) — {{ $dsar->institution->display_name }} @endif {{ \App\Enum\Dsar\DsarStatus::label($dsar->status) }}
@if($relinking) @else @endif
@endforeach
@elseif(strlen($dsarSearch) >= 2)

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

@endif
{{-- Re-linking: thread context / Unmatched: email body --}}
@if($relinking && $thread->isNotEmpty())
@foreach($thread as $msg) @php $isInbound = $msg->direction->value === 'inbound'; $isCurrent = $msg->id === $currentMessage->id; $dirBg = $isInbound ? '#eff6ff' : '#f9fafb'; $dirBorder = $isInbound ? '#bfdbfe' : '#e5e7eb'; $dirColor = $isInbound ? '#2563eb' : '#6b7280'; $dirLabel = $isInbound ? 'Inbound' : 'Outbound'; $dirIcon = $isInbound ? 'mdi-email-arrow-left-outline' : 'mdi-email-arrow-right-outline'; @endphp
@if($msg->body_html) @elseif($msg->body_text)
{{ $msg->body_text }}
@else

No body content.

@endif
@endforeach
@else
@if($currentMessage->body_html) @elseif($currentMessage->body_text)
{{ $currentMessage->body_text }}
@else

This email has no body content.

@endif
@endif
@endif
{{-- RIGHT: Attachments panel --}}
{{-- Panel header --}}
Attachments @if($currentMessage->attachments->isNotEmpty()) ({{ $currentMessage->attachments->count() }}) @endif
{{-- Panel content --}}
@if($currentMessage->attachments->isEmpty())
No attachments
@else
@foreach($currentMessage->attachments as $attachment) @php $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'); @endphp
{{-- Attachment header --}}
@if($attachment->size) {{ number_format($attachment->size / 1024, 1) }} KB @endif
{{-- Inline preview --}}
@if($isImage)
{{ $attachment->filename }}
@elseif($isPdf) {{-- PDFs must NOT be sandboxed: Chrome blocks its built-in PDF viewer inside a sandboxed iframe ("page blocked"). The viewer isolates the PDF from this origin, so a plain iframe is safe. --}} @else @endif
@endforeach
@endif
{{-- /split panels --}} @else {{-- ── EMPTY STATE ─────────────────────────────────────────────── --}}

All clear

@if($viewMode === 'mine') No pending emails matched to your clients in this section. @elseif($viewMode === 'mine_and_unmatched') No pending emails (matched or unmatched) in this section. @else No unmatched emails in this section. @endif

@if($viewMode === 'mine')

Try to also see unmatched emails.

@endif
@endif
{{-- Reply panel (position:fixed — must live outside the @if block) --}} @if($currentMessage) @endif