From d5895dc4a9d9d161fd17ebeb7d55b0304101b3aa Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Wed, 8 May 2024 00:26:04 +0800 Subject: [PATCH] feat: #62 add title section in website --- .../website/WebsiteMetricsTable.tsx | 1 + .../routes/website/$websiteId/index.tsx | 13 +++++++++-- src/client/vite.config.ts | 3 +++ src/server/trpc/routers/website.ts | 22 +++++++++++-------- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/client/components/website/WebsiteMetricsTable.tsx b/src/client/components/website/WebsiteMetricsTable.tsx index 1af44b0..f8a5dde 100644 --- a/src/client/components/website/WebsiteMetricsTable.tsx +++ b/src/client/components/website/WebsiteMetricsTable.tsx @@ -16,6 +16,7 @@ interface MetricsTableProps { | 'url' | 'language' | 'referrer' + | 'title' | 'browser' | 'os' | 'device' diff --git a/src/client/routes/website/$websiteId/index.tsx b/src/client/routes/website/$websiteId/index.tsx index 501530b..a084eac 100644 --- a/src/client/routes/website/$websiteId/index.tsx +++ b/src/client/routes/website/$websiteId/index.tsx @@ -128,7 +128,16 @@ function WebsiteDetailComponent() { endAt={endAt} /> - + + + + - + { - const current = Number(metrics[0][key]) || 0; - const prev = Number(prevPeriod[0][key]) || 0; - obj[key] = { - value: current, - prev, - }; - return obj; - }, {} as Record); + const stats = Object.keys(metrics[0]).reduce( + (obj, key) => { + const current = Number(metrics[0][key]) || 0; + const prev = Number(prevPeriod[0][key]) || 0; + obj[key] = { + value: current, + prev, + }; + return obj; + }, + {} as Record + ); return websiteStatsSchema.parse(stats); }), @@ -330,6 +333,7 @@ export const websiteRouter = router({ 'url', 'language', 'referrer', + 'title', 'browser', 'os', 'device',