// plane package imports import { observer } from "mobx-react-lite"; import { useParams } from "next/navigation"; import useSWR from "swr"; import { insightsFields } from "@plane/constants"; import { useTranslation } from "@plane/i18n"; import { IAnalyticsResponseV2, TAnalyticsTabsV2Base } from "@plane/types"; //hooks import { cn } from "@/helpers/common.helper"; import { useAnalyticsV2 } from "@/hooks/store/use-analytics-v2"; //services import { AnalyticsV2Service } from "@/services/analytics-v2.service"; // plane web components import InsightCard from "./insight-card"; const analyticsV2Service = new AnalyticsV2Service(); const TotalInsights: React.FC<{ analyticsType: TAnalyticsTabsV2Base; peekView?: boolean }> = observer( ({ analyticsType, peekView }) => { const params = useParams(); const workspaceSlug = params.workspaceSlug.toString(); const { t } = useTranslation(); const { selectedDuration, selectedProjects, selectedDurationLabel, selectedCycle, selectedModule, isPeekView } = useAnalyticsV2(); const { data: totalInsightsData, isLoading } = useSWR( `total-insights-${analyticsType}-${selectedDuration}-${selectedProjects}-${selectedCycle}-${selectedModule}-${isPeekView}`, () => analyticsV2Service.getAdvanceAnalytics( workspaceSlug, analyticsType, { // date_filter: selectedDuration, ...(selectedProjects?.length > 0 ? { project_ids: selectedProjects.join(",") } : {}), ...(selectedCycle ? { cycle_id: selectedCycle } : {}), ...(selectedModule ? { module_id: selectedModule } : {}), }, isPeekView ) ); return (
{insightsFields[analyticsType]?.map((item: string) => ( ))}
); } ); export default TotalInsights;