@extends('admin.layouts.app')
@section('title', __('dashboard.title'))
@section('header', __('dashboard.title'))
@section('header-actions')
@endsection
@section('content')
@php
use App\Http\Controllers\Admin\DashboardWidgetController;
$widgetMap = collect($widgets)->keyBy('id');
$isVisible = fn($id) => (bool)($widgetMap[$id]['visible'] ?? true);
$spanClass = function(string $span): string {
return match($span) {
'quarter' => 'col-span-12 sm:col-span-6 lg:col-span-3',
'half' => 'col-span-12 lg:col-span-6',
'two-thirds' => 'col-span-12 lg:col-span-8',
'one-third' => 'col-span-12 lg:col-span-4',
default => 'col-span-12',
};
};
$statusBadge = ['member'=>'badge-primary','supporter'=>'badge-success','donor'=>'badge-warning','vip'=>'badge-purple','inactive'=>'badge-secondary','prospect'=>'badge-info','volunteer'=>'badge-success'];
@endphp
@foreach($widgets as $widget)
@if($widget['visible'])
@php $wid = $widget['id']; $def = DashboardWidgetController::DEFS[$wid]; $sc = $spanClass($def['span']); @endphp
{{-- ── stat_contacts ─────────────────────────────────────── --}}
@if($wid === 'stat_contacts')
{{ number_format($stats['people']) }}
{{ __('dashboard.total_contacts') }}
+{{ $stats['new_people'] }} {{ __('dashboard.this_month') }}
{{-- ── stat_events ───────────────────────────────────────── --}}
@elseif($wid === 'stat_events')
{{ $stats['events'] }}
{{ __('dashboard.upcoming_events') }}
{{-- ── stat_donations ────────────────────────────────────── --}}
@elseif($wid === 'stat_donations')
{{ number_format($stats['donations'], 0, ',', ' ') }}
{{ __('dashboard.total_donations') }}
{{-- ── stat_subscribed ───────────────────────────────────── --}}
@elseif($wid === 'stat_subscribed')
{{ number_format($stats['subscribed']) }}
{{ __('dashboard.newsletter_subs') }}
{{-- ── chart_donations ───────────────────────────────────── --}}
@elseif($wid === 'chart_donations')
{{ __('dashboard.monthly_donations') }}
{{ __('dashboard.last_12_months_ft') }}
{{-- ── list_contacts ─────────────────────────────────────── --}}
@elseif($wid === 'list_contacts')
@forelse($recent_people as $person)
@if($person->photo)
@else
{{ strtoupper(substr($person->first_name, 0, 1)) }}
@endif
{{ __('dashboard.status.' . $person->status, [], null) ?? $person->status }}
@empty
{{ __('dashboard.no_contacts') }}
@endforelse
{{-- ── list_events ───────────────────────────────────────── --}}
@elseif($wid === 'list_events')
@forelse($upcoming_events as $event)
{{ $event->starts_at->format('d') }}
{{ $event->starts_at->format('M') }}
{{ $event->title }}
{{ $event->starts_at->format('H:i') }} · {{ $event->city ?? ($event->is_online ? __('common.online') : '—') }}
{{ $event->type }}
@empty
{{ __('dashboard.no_events') }}
@endforelse
{{-- ── chart_growth ──────────────────────────────────────── --}}
@elseif($wid === 'chart_growth')
{{ __('dashboard.contact_growth') }}
{{ __('dashboard.last_12_months') }}
{{ __('dashboard.contacts_label') }}
{{ __('dashboard.donations_label') }}
{{-- ── chart_status ──────────────────────────────────────── --}}
@elseif($wid === 'chart_status')
{{ __('dashboard.contact_distribution') }}
{{ __('dashboard.by_status') }}
@endif
@endif
@endforeach
{{-- ── Customizer drawer ─────────────────────────────────── --}}
{{ __('dashboard.customize_title') }}
{{ __('dashboard.customize_desc') }}
@foreach($widgets as $widget)
@php $def = DashboardWidgetController::DEFS[$widget['id']]; @endphp
@endforeach
{{ __('dashboard.customize_saved') }}
@push('scripts')
@endpush
@endsection