@php /** @var \App\Models\MetaCampaign $campaign */ /** @var \App\Services\MetaGraphClient $graph */ $isFailed = $campaign->status === 'FAILED'; $isDraft = $campaign->status === 'DRAFT'; $isActive = $campaign->status === 'ACTIVE'; $isPaused = $campaign->status === 'PAUSED'; $hasMeta = (bool) $campaign->facebook_id; $insights = is_array($campaign->insights) ? $campaign->insights : []; $currency = \App\Models\SystemSetting::get('default_currency', 'USD'); $statusPill = match (true) { $isActive => 'bg-emerald-50 text-emerald-700 ring-1 ring-emerald-200', $isPaused => 'bg-amber-50 text-amber-700 ring-1 ring-amber-200', $isFailed => 'bg-rose-50 text-rose-700 ring-1 ring-rose-200', $isDraft => 'bg-paper-50 text-ink-700 ring-1 ring-paper-200', default => 'bg-sky-50 text-sky-700 ring-1 ring-sky-200', }; @endphp
{{-- ============= Header ============= --}}
{{ __('Meta Ads') }} {{ $campaign->name }}

{{ $campaign->name }}

{{ ucfirst(strtolower((string) $campaign->objective)) ?: 'Click-to-WhatsApp' }} · Daily budget {{ number_format((float) $campaign->daily_budget, 2) }} {{ $currency }}

{{ ucfirst(strtolower($campaign->status)) }} @if ($hasMeta) @endif @if ($isFailed) @endif Edit
{{-- ============= Banners ============= --}} @if ($isFailed && !empty($campaign->meta_last_error))
{{ __('Sync to Meta failed') }}
{{ $campaign->meta_last_error }}
{{ __('Fix the issue + click') }} {{ __('Retry sync') }}. Common causes: missing fb_page_id on workspace, ad image below 1080 px, token without ads_management scope.
@endif @if ($isDraft)
{{ __('Draft — not on Meta yet') }}
{{ __('This campaign is saved locally. Edit it and choose status') }} {{ __('Paused') }} or {{ __('Active') }} to push the 5-step CTWA pipeline to Meta.
@endif @if (!$isCtwaReady && !$isDraft)
{{ __('CTWA prerequisites missing') }}
{{ __('This workspace needs Meta page_id + WABA id + phone_number_id configured before the ad can route taps to WhatsApp. Add them at') }} /devices.
@endif {{-- ============= Two-column body ============= --}}
{{-- ===== LEFT: Insights + creative preview ===== --}}

{{ __('Performance (last 7 days)') }}

@if ($campaign->meta_synced_at) Last synced {{ $campaign->meta_synced_at->diffForHumans() }} @endif
@php $tiles = [ [ 'Spend', (string) number_format((float) ($insights['spend'] ?? 0), 2) . ' ' . $currency, ], ['Impressions', (string) number_format((int) ($insights['impressions'] ?? 0))], ['Clicks', (string) number_format((int) ($insights['clicks'] ?? 0))], ['Reach', (string) number_format((int) ($insights['reach'] ?? 0))], ['Conversations', (string) number_format((int) ($insights['conversions'] ?? 0))], ['CTR', (string) number_format((float) ($insights['ctr'] ?? 0), 2) . '%'], ['CPC', (string) number_format((float) ($insights['cpc'] ?? 0), 2) . ' ' . $currency], ['Frequency', (string) number_format((float) ($insights['frequency'] ?? 0), 2)], ]; @endphp @foreach ($tiles as [$label, $value])
{{ $label }}
{{ $value }}
@endforeach

{{ __('Creative preview') }}

@if ($campaign->creative_image) @else
{{ __('No image') }}
@endif
{{ $campaign->creative_title ?: $campaign->name }}

{{ $campaign->creative_body }}

@if ($campaign->ctwa_enabled) @if ($campaign->ctwa_message)
"{{ $campaign->ctwa_message }}"
@endif @endif
{{-- ===== RIGHT: Meta tree IDs + targeting ===== --}}