@php /** @var \App\Models\WaTemplate $template */ $template = $template ?? null; $provider = $provider ?? null; $wabaSubmittable = $wabaSubmittable ?? false; $metaStatus = strtoupper((string) $template->meta_status); $localStatus = (string) $template->status; // Every Meta-side state we have to render. APPROVED + REJECTED are // terminal-ish; PENDING/IN_APPEAL/PENDING_DELETION are transient; // PAUSED/DISABLED/LIMIT_EXCEEDED/FLAGGED block sends. DELETED keeps // the row visible for audit but locks edit/send. $isPending = in_array($metaStatus, ['PENDING', 'IN_APPEAL', 'PENDING_DELETION'], true); $isApproved = $metaStatus === 'APPROVED'; $isRejected = $metaStatus === 'REJECTED'; $isPaused = $metaStatus === 'PAUSED' || ($template->paused_until && now()->lt($template->paused_until)); $isDisabled = in_array($metaStatus, ['DISABLED', 'LIMIT_EXCEEDED', 'FLAGGED', 'DELETED'], true); $quality = strtoupper((string) ($template->quality_score ?: 'UNKNOWN')); $statusPillClass = match (true) { $isApproved => 'bg-emerald-50 text-emerald-700 ring-1 ring-emerald-200', $isRejected => 'bg-rose-50 text-rose-700 ring-1 ring-rose-200', $isPaused => 'bg-amber-50 text-amber-700 ring-1 ring-amber-200', $isDisabled => 'bg-zinc-100 text-zinc-700 ring-1 ring-zinc-300', $isPending => 'bg-sky-50 text-sky-700 ring-1 ring-sky-200', default => 'bg-paper-50 text-ink-700 ring-1 ring-paper-200', }; $statusLabel = match ($metaStatus) { 'APPROVED' => 'Approved', 'REJECTED' => 'Rejected', 'PENDING' => 'In review', 'IN_APPEAL' => 'In appeal', 'PENDING_DELETION' => 'Deleting', 'DELETED' => 'Deleted', 'DISABLED' => 'Disabled', 'LIMIT_EXCEEDED' => 'Limit exceeded', 'FLAGGED' => 'Flagged', 'PAUSED' => 'Paused', default => $isPaused ? 'Paused' : ucfirst(strtolower($metaStatus ?: $localStatus ?: 'Draft')), }; $qualityPillClass = match ($quality) { 'GREEN' => 'bg-emerald-50 text-emerald-700 ring-1 ring-emerald-200', 'YELLOW' => 'bg-amber-50 text-amber-700 ring-1 ring-amber-200', 'RED' => 'bg-rose-50 text-rose-700 ring-1 ring-rose-200', default => 'bg-paper-50 text-ink-500 ring-1 ring-paper-200', }; $rejectionFriendly = match ($template->rejection_reason_code) { 'ABUSIVE_CONTENT' => 'Content was flagged as abusive or threatening.', 'INVALID_FORMAT' => 'Format violates Meta\'s template rules (placeholders, line breaks, length).', 'PROMOTIONAL' => 'Marketing language not allowed in this category.', 'TAG_CONTENT_MISMATCH' => 'Category does not match the content (e.g. promotional copy in a UTILITY template).', 'SCAM' => 'Meta flagged the template as a potential scam — review claims and language.', 'NONE' => null, default => $template->rejection_reason ?: null, }; $lintWarnings = (array) session('lint_warnings', []); @endphp
{{-- ============================================================ --}} {{-- HEADER ------------------------------------------------------ --}} {{-- ============================================================ --}}
{{ __('Templates') }} {{ $template->template_name }}

{{ $template->template_name }}

{{ strtoupper($template->meta_category ?: $template->category) }} · {{ $template->language ?: 'en_US' }} · {{ ucfirst($template->template_type ?: 'standard') }}

@if ($isPending) @elseif ($isApproved) @elseif ($isRejected) @endif {{ $statusLabel }} @if ($isApproved) Quality · {{ $quality }} @endif Edit
{{-- ============================================================ --}} {{-- BANNERS ----------------------------------------------------- --}} {{-- ============================================================ --}} @if ($isPending)
{{ __('Submitted for Meta review') }}
{{ __('Most templates are approved within minutes — Meta allows up to 48 hours. This page refreshes automatically every 30 seconds while the status is pending.') }}
@if ($template->submitted_at)
Submitted {{ $template->submitted_at->diffForHumans() }} @if ($template->last_synced_at) · last checked {{ $template->last_synced_at->diffForHumans() }} @endif
@endif
@endif @if ($isRejected)
{{ __('Rejected by Meta') }}
@if ($rejectionFriendly)
{{ $rejectionFriendly }}
@endif @if ($template->rejection_reason_code)
Code: {{ $template->rejection_reason_code }}
@endif
Edit & resubmit
@endif @if ($isPaused)
{{ __('Paused by Meta') }}
Repeated negative feedback (blocks/spam reports) paused this template. Quality score must recover before it can be sent again. @if ($template->paused_until) Auto-unpause after {{ $template->paused_until->format('M j, H:i') }}. @endif
@endif @foreach ($lintWarnings as $warning)
{{ $warning }}
@endforeach {{-- ============================================================ --}} {{-- TWO-COLUMN BODY -------------------------------------------- --}} {{-- ============================================================ --}}
{{-- ===== LEFT — Preview + components ===== --}}
{{-- Preview card --}}

{{ __('Preview') }}

{{ __('How it appears on WhatsApp') }}
@if ($template->attachment_type && $template->attachment_file) @if ($template->attachment_type === 'image') {{ __('header media') }} @elseif ($template->attachment_type === 'video')
{{ __('video header') }}
@else
{{ basename($template->attachment_file) }}
@endif @endif @if ($template->header && (!$template->attachment_type || $template->attachment_type === 'none'))
{{ $template->header }}
@endif
{{ $template->template_body }}
@if ($template->footer)
{{ $template->footer }}
@endif @if (is_array($template->buttons) && count($template->buttons))
@foreach ($template->buttons as $btn)
{{ $btn['text'] ?? '' }}
@endforeach
@endif
@if ($template->template_type === 'carousel' && is_array($template->carousel_data) && count($template->carousel_data))
@foreach ($template->carousel_data as $card)
@if (!empty($card['image'])) @endif
{{ $card['body'] ?? '' }}
@if (!empty($card['buttons']))
@foreach ($card['buttons'] as $b)
{{ $b['text'] ?? '' }}
@endforeach
@endif
@endforeach
@endif
{{-- Components breakdown --}}

{{ __('Components') }}

@if ($template->header)
{{ __('Header') }}
{{ $template->header }}
@endif
{{ __('Body') }}
{{ $template->template_body }}
@if ($template->footer)
{{ __('Footer') }}
{{ $template->footer }}
@endif @if (is_array($template->buttons) && count($template->buttons))
{{ __('Buttons') }}
@foreach ($template->buttons as $btn)
{{ $btn['type'] ?? 'quick_reply' }} {{ $btn['text'] ?? '' }} @if (!empty($btn['value'])) → {{ $btn['value'] }} @endif
@endforeach
@endif
{{-- ===== RIGHT — Meta sync sidebar ===== --}}