diff --git a/plane-src/apps/web/core/components/analytics/total-insights.tsx b/plane-src/apps/web/core/components/analytics/total-insights.tsx index 98e5ed0..5b72d39 100644 --- a/plane-src/apps/web/core/components/analytics/total-insights.tsx +++ b/plane-src/apps/web/core/components/analytics/total-insights.tsx @@ -22,6 +22,29 @@ import InsightCard from "./insight-card"; const analyticsService = new AnalyticsService(); +const WORK_ITEM_SUMMARY_FIELDS: IInsightField[] = [ + { + key: "total_work_items", + i18nKey: "workspace_analytics.total", + }, + { + key: "started_work_items", + i18nKey: "workspace_analytics.started_work_items", + }, + { + key: "backlog_work_items", + i18nKey: "workspace_analytics.backlog_work_items", + }, + { + key: "un_started_work_items", + i18nKey: "workspace_analytics.un_started_work_items", + }, + { + key: "completed_work_items", + i18nKey: "workspace_analytics.completed_work_items", + }, +]; + const getInsightLabel = ( analyticsType: TAnalyticsTabsBase, item: IInsightField, @@ -61,6 +84,13 @@ const TotalInsights = observer(function TotalInsights({ const workspaceSlug = params.workspaceSlug.toString(); const { t } = useTranslation(); const { selectedDuration, selectedProjects, selectedCycle, selectedModule, isPeekView, isEpic } = useAnalytics(); + const insightFields = + analyticsType === "work-items" + ? ANALYTICS_INSIGHTS_FIELDS[analyticsType]?.length + ? ANALYTICS_INSIGHTS_FIELDS[analyticsType] + : WORK_ITEM_SUMMARY_FIELDS + : (ANALYTICS_INSIGHTS_FIELDS[analyticsType] ?? []); + const shouldUseSummaryCard = analyticsType === "work-items"; const { data: totalInsightsData, isLoading } = useSWR( `total-insights-${analyticsType}-${selectedDuration}-${selectedProjects}-${selectedCycle}-${selectedModule}-${isEpic}`, () => @@ -77,18 +107,38 @@ const TotalInsights = observer(function TotalInsights({ isPeekView ) ); + + if (shouldUseSummaryCard) { + return ( +
+ {insightFields.map((item) => ( +
+
+ {getInsightLabel(analyticsType, item, isEpic, t)} +
+
+ {totalInsightsData?.[item.key]?.count ?? 0} +
+
+ ))} +
+ ); + } + return (
- {ANALYTICS_INSIGHTS_FIELDS[analyticsType]?.map((item) => ( + {insightFields.map((item) => (