forked from CircuitVerse/community-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.tsx
More file actions
41 lines (35 loc) · 1.14 KB
/
Copy pathpage.tsx
File metadata and controls
41 lines (35 loc) · 1.14 KB
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
// app/page.tsx
import {
ActivityGroup,
getMonthlyActivityBuckets,
getPreviousMonthActivityCount,
getRecentActivitiesGroupedByType,
getReposOverview,
} from "@/lib/db";
import { getConfig } from "@/lib/config";
import HomeDashboard from "@/components/home-dashboard"; // New Client Component
export default async function Home() {
const config = getConfig();
// 1. Fetch Existing Overview Data (Server Side)
const totalCount = (groups: ActivityGroup[]) =>
groups.reduce((sum, g) => sum + g.activities.length, 0);
const week = await getRecentActivitiesGroupedByType("week");
const month = await getRecentActivitiesGroupedByType("month");
const previousMonthCount = await getPreviousMonthActivityCount();
const bucketData = await getMonthlyActivityBuckets();
const reposOverview = await getReposOverview();
// 2. Bundle data for the client component
const overviewData = {
totalMonth: totalCount(month),
week,
month,
previousMonthCount,
bucketData,
config,
reposData: {
reposOverview
}
};
// 3. Pass data to the interactive dashboard
return <HomeDashboard overviewData={overviewData} />;
}