@php use Illuminate\Support\Str; $currentStatus = $currentStatus ?? 'all'; $currentType = $currentType ?? 'all'; $currentRange = $currentRange ?? 'all'; $currentSearch = $currentSearch ?? ''; $typeCounts = $typeCounts ?? ['all' => 0]; $total = $total ?? ($typeCounts['all'] ?? 0); $counts = $counts ?? ['scheduled' => 0, 'published' => 0, 'failed' => 0]; $selectedPage = (int) (request()->integer('page')); // Filter URL preserving the OTHER active filters (mirrors IG index). $filterUrl = function (array $o) use ($currentStatus, $currentType, $currentRange, $currentSearch, $selectedPage) { $q = array_filter([ 'account' => $selectedPage ?: null, 'status' => $o['status'] ?? ($currentStatus !== 'all' ? $currentStatus : null), 'type' => $o['type'] ?? ($currentType !== 'all' ? $currentType : null), 'range' => $o['range'] ?? ($currentRange !== 'all' ? $currentRange : null), 'q' => $o['q'] ?? ($currentSearch !== '' ? $currentSearch : null), ], fn ($v) => $v !== null && $v !== '' && $v !== 'all'); return route('user.facebook.posts') . ($q ? '?' . http_build_query($q) : ''); }; $statusPill = fn (string $s) => match ($s) { 'scheduled' => ['cls' => 'bg-accent-amber/15 text-[#7B5A14]', 'label' => __('Scheduled')], 'published' => ['cls' => 'bg-wa-mint text-wa-deep', 'label' => __('Published')], 'failed' => ['cls' => 'bg-accent-coral/10 text-accent-coral', 'label' => __('Failed')], 'draft' => ['cls' => 'bg-paper-100 text-ink-600', 'label' => __('Draft')], default => ['cls' => 'bg-paper-100 text-ink-600', 'label' => Str::title($s)], }; $statusTabs = [ ['key' => 'all', 'label' => __('All'), 'count' => $total], ['key' => 'scheduled', 'label' => __('Scheduled'), 'count' => $counts['scheduled'] ?? 0], ['key' => 'published', 'label' => __('Published'), 'count' => $counts['published'] ?? 0], ['key' => 'failed', 'label' => __('Failed'), 'count' => $counts['failed'] ?? 0], ]; @endphp
{{-- Header --}}
{{ __('Workspace') }} · {{ auth()->user()?->currentWorkspace?->name ?: __('Facebook') }}

{{ __('Facebook') }} {{ __('posts') }}

{{ __('Everything you have created, scheduled or published from :brand — track status, retry failures, and manage your queue.', ['brand' => brand_name()]) }}

@if ($pages->count() > 1)
@if ($currentStatus !== 'all')@endif
@endif {{ __('My posts') }} {{ __('Insights') }} {{ __('Create post') }}
@if (session('status'))
{{ session('status') }}
@endif @if ($pages->isEmpty())
{{ __('No Facebook Page connected yet') }}

{{ __('Connect a Facebook account to publish and schedule Page posts.') }}

{{ __('Connect a Facebook account') }}
@else {{-- KPI cards --}}
{{ __('Total posts') }}
{{ number_format($total) }}
{{ __('Scheduled') }}
{{ number_format($counts['scheduled'] ?? 0) }}
{{ __('Published') }}
{{ number_format($counts['published'] ?? 0) }}
{{ __('Failed') }}
{{ number_format($counts['failed'] ?? 0) }}
{{-- Status tabs + range + search --}}
@foreach ($statusTabs as $st) @php $active = $currentStatus === $st['key']; @endphp {{ $st['label'] }}{{ number_format($st['count']) }} @endforeach
@foreach ([['all', __('All time')], ['7d', __('7d')], ['30d', __('30d')], ['90d', __('90d')]] as [$rk, $rl]) @php $active = $currentRange === $rk; @endphp {{ $rl }} @endforeach
@if ($selectedPage)@endif @if ($currentStatus !== 'all')@endif
{{-- ===== TABLE ===== --}}
@forelse ($posts as $post) @php $pill = $statusPill($post->status); $thumb = data_get($post->media_json, 'photos.0'); @endphp @empty @endforelse
{{ __('Post') }} {{ __('Page') }} {{ __('Type') }} {{ __('Status') }} {{ __('When') }} {{ __('Actions') }}
@if ($thumb) @else @endif {{ $post->message ?: ($post->link ?: '['.str_replace('_', ' ', $post->type).']') }} @if ($post->error){{ Str::limit($post->error, 80) }}@endif
{{ $post->page?->name ?: '—' }} {{ str_replace('_', ' ', $post->type) }} {{ $pill['label'] }} @if ($post->status === 'scheduled' && $post->scheduled_publish_time) {{ $post->scheduled_publish_time->diffForHumans() }} @elseif ($post->published_at){{ $post->published_at->diffForHumans() }} @else {{ $post->created_at->diffForHumans() }}@endif
@if (in_array($post->status, ['failed', 'draft'], true))
@csrf
@endif
@csrf @method('DELETE')
{{ $total > 0 ? __('No posts match these filters') : __('No posts yet') }}

{{ __('Compose your first post — publish now or schedule it.') }}

{{ __('Create post') }}
@if ($posts->hasPages())
{{ $posts->withQueryString()->links() }}
@endif
@endif