From 9b7adb5504fd326a78c9dfbf7979cf759fee377b Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Wed, 15 Nov 2023 21:53:27 +0800 Subject: [PATCH] feat: add dashboard websiteEvent item --- src/client/components/dashboard/AddButton.tsx | 63 ++++++++++--------- .../dashboard/items/WebsiteEventItem.tsx | 22 +++++++ .../components/dashboard/items/index.tsx | 5 ++ .../components/website/MetricsTable.tsx | 2 +- src/client/store/dashboard.ts | 14 ++--- 5 files changed, 69 insertions(+), 37 deletions(-) create mode 100644 src/client/components/dashboard/items/WebsiteEventItem.tsx diff --git a/src/client/components/dashboard/AddButton.tsx b/src/client/components/dashboard/AddButton.tsx index 71f5ffc..ecf3191 100644 --- a/src/client/components/dashboard/AddButton.tsx +++ b/src/client/components/dashboard/AddButton.tsx @@ -1,4 +1,4 @@ -import { Button, Dropdown, Space } from 'antd'; +import { Button, Dropdown, MenuProps, Space } from 'antd'; import React from 'react'; import { trpc } from '../../api/trpc'; import { useCurrentWorkspaceId } from '../../store/user'; @@ -12,37 +12,42 @@ export const DashboardItemAddButton: React.FC = React.memo(() => { }); const { addItem } = useDashboardStore(); - return ( -
- ({ + key: `website#${website.id}`, + label: website.name, + children: [ { - key: 'website', - label: 'website', - children: websites.map((website) => ({ - key: `website#${website.id}`, - label: website.name, - children: [ - { - key: `website#${website.id}#overview`, - label: 'overview', - onClick: () => { - addItem( - 'websiteOverview', - website.id, - `${website.name}'s Overview` - ); - }, - }, - ], - })), + key: `website#${website.id}#overview`, + label: 'Overview', + onClick: () => { + addItem( + 'websiteOverview', + website.id, + `${website.name}'s Overview` + ); + }, + }, + { + key: `website#${website.id}#event`, + label: 'Events', + onClick: () => { + addItem('websiteEvent', website.id, `${website.name}'s Event`); + }, }, ], - }} - > + })), + }, + ], + }; + + return ( +
+