Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | 1x 3x 3x 3x 3x 1x 2x 2x 2x 2x 2x 1x | import { Card, CardHeader, CardTitle, CardContent } from '@core/components/ui/card'
import { useTranslation } from 'react-i18next'
import { Link } from 'react-router-dom'
import { useEvents } from '@features/events/hooks/useEvents'
import { useCurrencyFormatter } from '@core/hooks/useCurrencyFormatter'
import { Loader2, TrendingUp, Users, Calendar } from 'lucide-react'
import { DonationChart } from '../components/DonationChart'
import { RecentActivity } from '../components/RecentActivity'
import { EventCard } from '@features/events/components/EventCard'
export const DashboardPage = () => {
const { t } = useTranslation('common')
const { events, isLoading } = useEvents()
const { formatCurrency } = useCurrencyFormatter()
if (isLoading) {
return (
<div className="flex h-full items-center justify-center">
<Loader2 className="h-8 w-8 animate-spin" />
</div>
)
}
// Aggregations
const totalRaised = events.reduce((sum, e) => sum + (e.raised || 0), 0)
const totalDonors = events.reduce((sum, e) => sum + (e.donorCount || 0), 0)
const activeEvents = events.filter((e) => e.status?.toUpperCase() === 'ACTIVE')
const activeEventsCount = activeEvents.length
return (
<div className="space-y-8">
<div className="flex flex-col md:flex-row justify-between gap-4 items-start md:items-center">
<div>
<h2
className="text-3xl font-bold tracking-tight"
style={{ color: 'var(--admin-heading-color)' }}
>
{t('dashboard.title')}
</h2>
<p className="text-muted-foreground mt-2">{t('dashboard.platform_overview')}</p>
</div>
</div>
{/* Global Stats */}
<div className="grid gap-4 md:grid-cols-3">
<Card
style={{
backgroundColor: 'var(--admin-card-bg)',
borderColor: 'var(--admin-border-color)',
}}
>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">
{t('dashboard.stats.revenue')}
</CardTitle>
<TrendingUp className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div
className="text-2xl font-bold"
style={{ color: 'var(--admin-card-text)' }}
>
{formatCurrency(totalRaised)}
</div>
<p className="text-xs text-muted-foreground">
{t('dashboard.stats.events_count', { count: events.length })}
</p>
</CardContent>
</Card>
<Card
style={{
backgroundColor: 'var(--admin-card-bg)',
borderColor: 'var(--admin-border-color)',
}}
>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">
{t('dashboard.stats.active_events')}
</CardTitle>
<Calendar className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div
className="text-2xl font-bold"
style={{ color: 'var(--admin-card-text)' }}
>
{activeEventsCount}
</div>
<p className="text-xs text-muted-foreground">
{t('dashboard.stats.currently_live')}
</p>
</CardContent>
</Card>
<Card
style={{
backgroundColor: 'var(--admin-card-bg)',
borderColor: 'var(--admin-border-color)',
}}
>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">
{t('dashboard.stats.total_donors')}
</CardTitle>
<Users className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div
className="text-2xl font-bold"
style={{ color: 'var(--admin-card-text)' }}
>
{totalDonors}
</div>
<p className="text-xs text-muted-foreground">
{t('dashboard.stats.donors_description')}
</p>
</CardContent>
</Card>
</div>
<div className="grid gap-4 md:grid-cols-1 lg:grid-cols-7">
<div className="lg:col-span-4">
<DonationChart />
</div>
<div className="lg:col-span-3">
<RecentActivity />
</div>
</div>
{/* Active Events Grid */}
<div className="space-y-4">
<h3 className="text-xl font-semibold tracking-tight">
{t('dashboard.campaigns.title')}
</h3>
{activeEvents.length === 0 ? (
<div className="p-8 border border-dashed rounded-lg text-center text-muted-foreground">
{t('dashboard.campaigns.empty')}{' '}
<Link to="/admin/events" className="underline hover:text-primary">
{t('dashboard.campaigns.view_all')}
</Link>
</div>
) : (
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
{activeEvents.map((event) => (
<EventCard key={event.id} event={event} variant="compact" />
))}
</div>
)}
</div>
</div>
)
}
|