diff --git a/apps/web/app/(all)/[workspaceSlug]/(projects)/analytics/[tabId]/page.tsx b/apps/web/app/(all)/[workspaceSlug]/(projects)/analytics/[tabId]/page.tsx index 13e5177d6..8b9621521 100644 --- a/apps/web/app/(all)/[workspaceSlug]/(projects)/analytics/[tabId]/page.tsx +++ b/apps/web/app/(all)/[workspaceSlug]/(projects)/analytics/[tabId]/page.tsx @@ -1,14 +1,15 @@ -import { useMemo } from "react"; +"use client"; + +import { useState, useEffect } from "react"; import { observer } from "mobx-react"; import { useRouter } from "next/navigation"; // plane package imports import { EUserPermissions, EUserPermissionsLevel, PROJECT_TRACKER_ELEMENTS } from "@plane/constants"; import { useTranslation } from "@plane/i18n"; import { EmptyStateDetailed } from "@plane/propel/empty-state"; -import type { AnalyticsTab } from "@plane/types"; -import { Tabs } from "@plane/ui"; -import type { TabItem } from "@plane/ui"; +import { Tabs } from "@plane/propel/tabs"; // components +import { cn } from "@plane/utils"; import AnalyticsFilterActions from "@/components/analytics/analytics-filter-actions"; import { PageHead } from "@/components/core/page-title"; // hooks @@ -17,7 +18,7 @@ import { useCommandPalette } from "@/hooks/store/use-command-palette"; import { useProject } from "@/hooks/store/use-project"; import { useWorkspace } from "@/hooks/store/use-workspace"; import { useUserPermissions } from "@/hooks/store/user"; -import { getAnalyticsTabs } from "@/plane-web/components/analytics/tabs"; +import { useAnalyticsTabs } from "@/plane-web/components/analytics/use-analytics-tabs"; import type { Route } from "./+types/page"; function AnalyticsPage({ params }: Route.ComponentProps) { @@ -35,31 +36,32 @@ function AnalyticsPage({ params }: Route.ComponentProps) { const { currentWorkspace } = useWorkspace(); const { allowPermissions } = useUserPermissions(); + const pageTitle = currentWorkspace?.name + ? t(`workspace_analytics.page_label`, { workspace: currentWorkspace?.name }) + : undefined; + // permissions const canPerformEmptyStateActions = allowPermissions( [EUserPermissions.ADMIN, EUserPermissions.MEMBER], EUserPermissionsLevel.WORKSPACE ); - // derived values - const pageTitle = currentWorkspace?.name - ? t(`workspace_analytics.page_label`, { workspace: currentWorkspace?.name }) - : undefined; - const ANALYTICS_TABS = useMemo(() => getAnalyticsTabs(t), [t]); - const tabs: TabItem[] = useMemo( - () => - ANALYTICS_TABS.map((tab) => ({ - key: tab.key, - label: tab.label, - content: , - onClick: () => { - router.push(`/${currentWorkspace?.slug}/analytics/${tab.key}`); - }, - disabled: tab.isDisabled, - })), - [ANALYTICS_TABS, router, currentWorkspace?.slug] - ); - const defaultTab = tabId; + const workspaceSlug = params.workspaceSlug; + const ANALYTICS_TABS = useAnalyticsTabs(workspaceSlug.toString()); + + const [selectedTab, setSelectedTab] = useState(tabId || ANALYTICS_TABS[0]?.key); + + useEffect(() => { + if (tabId) { + setSelectedTab(tabId); + } + }, [tabId]); + + // Handle tab change + const handleTabChange = (value: string) => { + setSelectedTab(value); + router.push(`/${currentWorkspace?.slug}/analytics/${value}`); + }; return ( <> @@ -67,19 +69,43 @@ function AnalyticsPage({ params }: Route.ComponentProps) { {workspaceProjectIds && ( <> {workspaceProjectIds.length > 0 || loader === "init-loader" ? ( -
- } - /> +
+ +
+
+ + {ANALYTICS_TABS.map((tab) => ( + + {tab.label} + + ))} + + +
+ +
+
+ {ANALYTICS_TABS.map((tab) => ( + + + + ))} +
+
) : ( { + const { t } = useTranslation(); + + const analyticsTabs = useMemo(() => getAnalyticsTabs(t), [t]); + + return analyticsTabs; +}; diff --git a/apps/web/core/components/analytics/analytics-filter-actions.tsx b/apps/web/core/components/analytics/analytics-filter-actions.tsx index dad42c0a0..2c10cf7eb 100644 --- a/apps/web/core/components/analytics/analytics-filter-actions.tsx +++ b/apps/web/core/components/analytics/analytics-filter-actions.tsx @@ -4,11 +4,10 @@ import { observer } from "mobx-react"; import { useAnalytics } from "@/hooks/store/use-analytics"; import { useProject } from "@/hooks/store/use-project"; // components -import DurationDropdown from "./select/duration"; import { ProjectSelect } from "./select/project"; const AnalyticsFilterActions = observer(function AnalyticsFilterActions() { - const { selectedProjects, selectedDuration, updateSelectedProjects, updateSelectedDuration } = useAnalytics(); + const { selectedProjects, updateSelectedProjects } = useAnalytics(); const { joinedProjectIds } = useProject(); return (
diff --git a/apps/web/core/components/analytics/overview/active-project-item.tsx b/apps/web/core/components/analytics/overview/active-project-item.tsx index e579f8de5..710e0f0dd 100644 --- a/apps/web/core/components/analytics/overview/active-project-item.tsx +++ b/apps/web/core/components/analytics/overview/active-project-item.tsx @@ -1,6 +1,7 @@ // plane package imports import { Logo } from "@plane/propel/emoji-icon-picker"; import { ProjectIcon } from "@plane/propel/icons"; +import { Tooltip } from "@plane/propel/tooltip"; import { cn } from "@plane/utils"; // plane web hooks import { useProject } from "@/hooks/store/use-project"; @@ -33,9 +34,9 @@ function ActiveProjectItem(props: Props) { if (!projectDetails) return null; return ( -
-
-
+
+
+
{projectDetails?.logo_props ? ( @@ -46,13 +47,15 @@ function ActiveProjectItem(props: Props) { )}
-

{projectDetails?.name}

+ +

{projectDetails?.name}

+
); -} +}; export default ActiveProjectItem; diff --git a/packages/propel/src/tabs/tabs.tsx b/packages/propel/src/tabs/tabs.tsx index 08cec2d95..c86be241f 100644 --- a/packages/propel/src/tabs/tabs.tsx +++ b/packages/propel/src/tabs/tabs.tsx @@ -41,7 +41,7 @@ const TabsList = React.forwardRef(function TabsList(