|
| 1 | +import { useCurrentUser } from "@/auth/hooks"; |
| 2 | +import { |
| 3 | + useReconnectReminders, |
| 4 | + useUpcomingGroups, |
| 5 | + usePeople, |
| 6 | +} from "@/dashboard/hooks"; |
| 7 | +import { useDocumentTitle } from "@/lib/use-document-title"; |
| 8 | +import { getGreeting } from "@/lib/greeting"; |
| 9 | +import { StatCard } from "@/components/StatCard"; |
| 10 | + |
| 11 | +function displayNameFromEmail(email: string | undefined): string { |
| 12 | + if (!email) return ""; |
| 13 | + const localPart = email.split("@")[0] ?? ""; |
| 14 | + return localPart.charAt(0).toUpperCase() + localPart.slice(1); |
| 15 | +} |
| 16 | + |
1 | 17 | export default function DashboardPage() { |
| 18 | + useDocumentTitle("Dashboard"); |
| 19 | + |
| 20 | + const { data: user } = useCurrentUser(); |
| 21 | + const reconnectQuery = useReconnectReminders(); |
| 22 | + const upcomingQuery = useUpcomingGroups(); |
| 23 | + const peopleQuery = usePeople(); |
| 24 | + |
| 25 | + const displayName = displayNameFromEmail(user?.email); |
| 26 | + const greeting = getGreeting(); |
| 27 | + const heading = displayName ? `${greeting}, ${displayName}` : greeting; |
| 28 | + |
| 29 | + const reconnectCount = reconnectQuery.data?.length ?? 0; |
| 30 | + const upcomingCount = upcomingQuery.data?.length ?? 0; |
| 31 | + const peopleCount = peopleQuery.data?.length ?? 0; |
| 32 | + |
2 | 33 | return ( |
3 | | - <div className="space-y-2"> |
4 | | - <h1 className="text-2xl font-semibold tracking-tight">Dashboard</h1> |
5 | | - <p className="text-sm text-muted-foreground"> |
6 | | - Reconnect prompts and upcoming events land here in M6. |
7 | | - </p> |
| 34 | + <div className="space-y-6"> |
| 35 | + <h1 className="text-stat font-medium tracking-tight">{heading}</h1> |
| 36 | + |
| 37 | + <div className="grid grid-cols-1 gap-2.5 sm:grid-cols-3"> |
| 38 | + <StatCard |
| 39 | + label="Time to reconnect" |
| 40 | + value={reconnectCount} |
| 41 | + tone="orange" |
| 42 | + /> |
| 43 | + <StatCard label="Coming up soon" value={upcomingCount} /> |
| 44 | + <StatCard label="In your cirle" value={peopleCount} /> |
| 45 | + </div> |
8 | 46 | </div> |
9 | 47 | ); |
10 | 48 | } |
0 commit comments