@php $connected = ! $accounts->isEmpty(); $needsReconnect = $connected ? $accounts->first(fn ($a) => in_array($a->status, ['expiring', 'expired'], true)) : null; $pillMap = [ 'scheduled' => ['bg-[#13478A]/10', 'text-[#13478A]', 'border-[#13478A]/30', 'bg-[#13478A]'], 'processing' => ['bg-accent-amber/10', 'text-[#7B5A14]', 'border-accent-amber/30', 'bg-accent-amber'], 'published' => ['bg-wa-green/10', 'text-wa-deep', 'border-wa-green/30', 'bg-wa-green'], 'failed' => ['bg-accent-coral/10', 'text-[#A1431F]', 'border-accent-coral/30', 'bg-accent-coral'], ]; $cPub = $posts->where('status', 'published')->count(); $cSch = $posts->whereIn('status', ['scheduled', 'processing'])->count(); $cFail = $posts->where('status', 'failed')->count(); $tabs = [ ['key' => 'all', 'label' => __('All'), 'count' => $posts->count()], ['key' => 'published', 'label' => __('Published'), 'count' => $cPub], ['key' => 'scheduled', 'label' => __('Scheduled'), 'count' => $cSch], ['key' => 'failed', 'label' => __('Failed'), 'count' => $cFail], ]; @endphp
{{-- Flash --}} @if (session('status'))
{{ session('status') }}
@endif @if (session('error'))
{{ session('error') }}
@endif {{-- ===== Header ===== --}}
{{ __('X / Publishing') }}

{{ __('Publish to') }} X.

{{ __('Compose, schedule and track posts to X — right from your social calendar. X uses its own pay-per-use API, so you connect your own X developer keys.') }}

@if ($connected)
{{ $accounts->count() }} {{ __('connected') }} @if (\App\Services\PlanLimitGuard::hasFeature(auth()->user()?->currentWorkspace, 'x_insights')) {{ __('Insights') }} @endif @if (\App\Services\PlanLimitGuard::hasFeature(auth()->user()?->currentWorkspace, 'x_replies')) {{ __('Reply automation') }} @endif {{ __('Add account') }} {{ __('New post') }}
@endif
@php $ws = auth()->user()?->currentWorkspace; $ownX = $ws?->ownXApp(); $xClientId = $ws?->x_client_id; $xSecretSet = ! empty($ws?->x_client_secret); $xRedirect = url('/x/callback'); $xManual = (bool) \App\Models\SystemSetting::get('x_allow_manual_app', false); @endphp {{-- ===== Use your own app keys — shown when the admin allows it (or keys already set) ===== --}} @if ($xManual || $ownX)
{{ __('Connect with your own X app keys') }} {{ $ownX ? __('Using your app') : __('Required for X') }}

{{ __('X uses a pay-per-use API, so you connect your OWN X developer app and X bills your account directly. Paste your OAuth 2.0 Client ID + Secret below, then Connect.') }}

@csrf
{{ __('In your X app → User authentication settings (type: Web App, permissions: Read and write), add this callback URL:') }}
{{ $xRedirect }}
{{ __('Scopes: tweet.read, tweet.write, users.read, media.write, offline.access. Save, then click Connect.') }}
@endif @if (! $connected) {{-- ===== Empty state ===== --}}
{!! \App\Support\SvgIcon::inner('brands', 'x') !!}

{{ __('Connect X') }}

{{ __('Publish and schedule posts to X from here. Connect your own X developer app to post.') }}

{!! \App\Support\SvgIcon::inner('brands', 'x') !!}{{ __('Connect X') }}
{{ __('X uses its own paid API. You connect your own X developer keys, and X bills your account directly for posts. Publishing only — direct messages are not included.') }}
@else @if ($needsReconnect)
{{ __('A connected X account needs to be reconnected to keep posting.') }} {{ __('Reconnect') }}
@endif {{-- ===== Status tabs ===== --}}
@foreach ($tabs as $tab) @endforeach
{{-- ===== Showing + legend ===== --}}
{{ __('Showing') }} {{ $posts->count() }} {{ __('posts') }} {{ __('Published') }} {{ __('Scheduled') }} {{ __('Failed') }}
@if ($posts->isEmpty())

{{ __('No posts yet.') }}

{{ __('Create your first post') }}
@else
@foreach ($posts as $p) @php $st = strtolower($p->status); $tabStatus = in_array($st, ['scheduled', 'processing'], true) ? 'scheduled' : $st; $pill = $pillMap[$st] ?? $pillMap['scheduled']; $thumb = $p->image_url ?: null; $acc = $p->account; $accName = $acc?->name ?: ($acc?->username ?: 'X'); $accHandle = $acc?->username; $accAvatar = $acc?->profile_image_url; $avStyle = $accAvatar ? "background-image:url('".e($accAvatar)."');background-size:cover;background-position:center" : 'background:#000'; @endphp
{{ ucfirst($st) }} {{ $p->media_type }}
@if (! $accAvatar){!! \App\Support\SvgIcon::inner('brands', 'x') !!}@endif
{{ $accName }} @if($accHandle){{ '@'.$accHandle }}@endif
{{ $p->text ?: '('.$p->media_type.')' }}
@if ($thumb)
@endif
@if ($p->last_error)
{{ \Illuminate\Support\Str::limit($p->last_error, 90) }}
@endif
@if ($p->published_at) {{ $p->published_at->format('M j, H:i') }} @elseif ($p->scheduled_at) {{ __('Sched') }} · {{ $p->scheduled_at->format('M j, H:i') }} @else {{ $p->created_at?->format('M j, H:i') }} @endif @if ($p->status !== 'published')
@csrf @method('DELETE')
@endif
@endforeach
@endif @endif
@push('scripts') @endpush