@php /** Shared card markup for /meta-ads — rendered both in the * full page and via the JSON `partial` mode the JS uses for * filter / search / sort updates without a full reload. */ $statusPillClasses = [ 'ACTIVE' => [ 'bg' => 'bg-wa-green/10', 'text' => 'text-wa-deep', 'border' => 'border-wa-green/30', 'dot' => 'bg-wa-green', ], 'PAUSED' => [ 'bg' => 'bg-[#EFE5F5]', 'text' => 'text-[#5B3D8A]', 'border' => 'border-[#D9C7E8]', 'dot' => 'bg-[#5B3D8A]', ], 'SCHEDULED' => [ 'bg' => 'bg-[#13478A]/10', 'text' => 'text-[#13478A]', 'border' => 'border-[#13478A]/30', 'dot' => 'bg-[#13478A]', ], 'DRAFT' => [ 'bg' => 'bg-paper-50', 'text' => 'text-ink-700', 'border' => 'border-paper-200', 'dot' => 'bg-paper-300', ], 'FAILED' => [ 'bg' => 'bg-accent-coral/10', 'text' => 'text-[#A1431F]', 'border' => 'border-accent-coral/30', 'dot' => 'bg-accent-coral', ], ]; $objectiveLabels = [ 'MESSAGES' => 'Messages', 'LINK_CLICKS' => 'Link clicks', 'LEAD_GENERATION' => 'Lead gen', 'CONVERSIONS' => 'Conversions', 'BRAND_AWARENESS' => 'Brand awareness', 'REACH' => 'Reach', 'VIDEO_VIEWS' => 'Video views', ]; @endphp @forelse ($campaigns as $c) @php $pill = $statusPillClasses[$c->status] ?? $statusPillClasses['DRAFT']; $metrics = $c->metrics; $isPaused = $c->status === 'PAUSED'; $iconBg = $c->status === 'ACTIVE' ? 'bg-wa-bubble text-wa-deep' : 'bg-paper-100 text-ink-700'; @endphp
@if ($c->status === 'FAILED' && !empty($c->meta_last_error))
{{ __('Meta sync failed') }}
{{ mb_substr((string) $c->meta_last_error, 0, 180) }}
View details & retry
@endif
@if ($isPaused) @else @endif
{{ $c->name }}
{{-- Use the Meta ad-account's OWN currency (persisted from the Graph API's account_currency, e.g. IDR → Rp) — same source the analytics page uses. The old `$c->ad_account?->currency` read a relationship that doesn't exist on MetaCampaign, so it always fell through to the USD default and mislabeled Rupiah spend. --}} @php $adCur = strtoupper((string) ($c->insights['account_currency'] ?? '')) ?: \App\Models\SystemSetting::get('default_currency', 'USD'); @endphp
{{ $objectiveLabels[$c->optimization_goal] ?? $c->optimization_goal }} · Budget: {!! \App\Support\FormatSettings::display($c->daily_budget, $adCur) !!}/day
{{ ucfirst(strtolower($c->status)) }} @if ($c->facebook_id) @endif
{{ __('Spend') }}
{!! \App\Support\FormatSettings::display($metrics['spend'], $adCur) !!}
{{ __('Impressions') }}
{{ number_format($metrics['impressions']) }}
{{ __('Clicks') }}
{{ number_format($metrics['clicks']) }}
{{ __('Reach') }}
{{ number_format($metrics['reach']) }}
{{ __('Conversions') }}
{{ number_format($metrics['conversions']) }}
{{ __('CTR') }}
{{ number_format($metrics['ctr'], 2) }}%
{{ __('CPC') }}
{!! \App\Support\FormatSettings::display($metrics['cpc'], $adCur) !!}
{{ __('Revenue') }}
{!! \App\Support\FormatSettings::display($metrics['revenue'], $adCur) !!}
Created: {{ $c->created_at?->format('Y-m-d') }} {{ $c->ad_set_count }} Ad Set(s) {{ $c->ad_count }} Ad(s) @if ($c->facebook_id) FB ID: {{ \Illuminate\Support\Str::limit($c->facebook_id, 12, '…') }} @elseif ($c->status !== 'DRAFT') {{-- Not on Meta: the campaign was saved locally but never created on the Marketing API, so it can never show spend/impressions (all 0) even while it reads ACTIVE. Let the user push it now. --}} {{ __('Not on Meta') }} @endif @if ($c->meta_last_error && !$c->facebook_id && $c->status !== 'FAILED') {{ \Illuminate\Support\Str::limit($c->meta_last_error, 60, '…') }} @endif @if ($c->ctwa_enabled) {{ __('Click-to-WhatsApp') }} @endif
@empty @include('user.partials.empty-state', [ 'message' => 'No Meta Ads campaigns match the current filters. Try clearing filters or create a new campaign.', 'resetHref' => url('/meta-ads'), 'actionHref' => route('user.meta-ads.create'), 'actionLabel' => 'Create campaign', ]) @endforelse