@props([
'workspace' => null,
'detailed' => false,
])
@php
$ws = $workspace ?: auth()->user()?->currentWorkspace;
$u = $ws ? \App\Services\PlanUsage::summary($ws) : null;
@endphp
@if ($u)
{{-- ============ HERO PLAN CARD ============ --}}
{{ __('Current plan') }}
{{ $u['plan_name'] }}
{{ __('active') }}
{{ __('Resets :date · :days days left in this cycle', ['date' => $u['cycle_reset'], 'days' => $u['days_left']]) }}
{{-- Big monthly-usage meter --}}
{{ __('Messages used') }} · {{ $u['month_label'] }}
{{ number_format($u['messages_used']) }}
@if ($u['messages_unlimited'])
/ {{ __('Unlimited') }}
@else
/ {{ number_format($u['messages_limit']) }}
@endif
@php $heroBar = $u['messages_pct'] >= 90 ? 'bg-accent-coral' : 'bg-paper-0'; @endphp
@if ($u['messages_unlimited'])
{{ __('Your plan has no monthly message cap.') }}
@else
{{ __(':n messages remaining', ['n' => number_format($u['messages_remaining'])]) }}
@if ($u['messages_remaining'] === 0)
· {{ __('extra sends bill from wallet credits') }}
@endif
@endif
{{-- ============ STAT TILES ============ --}}
@php
$tiles = [
[
'label' => __('Wallet credits'),
'value' => number_format($u['credits']),
'href' => url('/account?tab=wallet'),
],
[
'label' => __('Features unlocked'),
'value' => $u['unlocked_count'] . ' / ' . $u['feature_total'],
'href' => url('/account/plans'),
],
['label' => __('Sent this month'), 'value' => number_format($u['messages_used']), 'href' => null],
['label' => __('Days left in cycle'), 'value' => $u['days_left'], 'href' => null],
];
@endphp
@foreach ($tiles as $t)
<{{ $t['href'] ? 'a' : 'div' }} @if ($t['href']) href="{{ $t['href'] }}" @endif
class="rounded-2xl bg-paper-0 border border-paper-200 shadow-card p-4 {{ $t['href'] ? 'hover:border-wa-deep transition' : '' }}">
{{ $t['label'] }}
{{ $t['value'] }}
{{ $t['href'] ? 'a' : 'div' }}>
@endforeach
@if ($detailed)
{{-- ============ USAGE & LIMITS ============ --}}
{{ __('Usage & limits') }}
{{ __('This billing cycle') }}
@foreach ($u['meters'] as $m)
{{ __($m['label']) }}
{{ number_format($m['used']) }}
/
{{ $m['unlimited'] ? '∞' : number_format($m['limit']) }}
@endforeach
@endif
{{-- ============ FEATURES (all, with included / locked state) ============ --}}
{{ __('Features') }}
{{ __('What :plan includes', ['plan' => $u['plan_name']]) }}
{{ $u['unlocked_count'] }}/{{ $u['feature_total'] }}
{{ __('on') }}
@foreach ($u['unlocked'] as $label)
@endforeach
@foreach ($u['locked'] as $label)
@endforeach
@if (count($u['locked']))
@endif
@else
{{-- No active workspace (or plan summary unavailable) — never leave the
tab blank. Give a clear call to action instead of an empty panel. --}}
{{ __('No active plan yet') }}
{{ __('Pick a plan to unlock messaging limits, automations, and team features. Your usage meters appear here once a workspace is active.') }}
{{ __('View plans') }}
@endif