import { observer } from "mobx-react"; import { useParams } from "next/navigation"; import { useForm } from "react-hook-form"; import useSWR from "swr"; import { IAnalyticsParams } from "@plane/types"; // services // components import { CustomAnalyticsSelectBar, CustomAnalyticsMainContent, CustomAnalyticsSidebar } from "@/components/analytics"; // types // fetch-keys import { ANALYTICS } from "@/constants/fetch-keys"; import { cn } from "@/helpers/common.helper"; import { useAppTheme } from "@/hooks/store"; import { AnalyticsService } from "@/services/analytics.service"; type Props = { additionalParams?: Partial; fullScreen: boolean; }; const defaultValues: IAnalyticsParams = { x_axis: "priority", y_axis: "issue_count", segment: null, project: null, }; const analyticsService = new AnalyticsService(); export const CustomAnalytics: React.FC = observer((props) => { const { additionalParams, fullScreen } = props; const { workspaceSlug, projectId } = useParams(); const { control, watch, setValue } = useForm({ defaultValues }); const params: IAnalyticsParams = { x_axis: watch("x_axis"), y_axis: watch("y_axis"), segment: watch("segment"), project: projectId ? [projectId.toString()] : watch("project"), ...additionalParams, }; const { data: analytics, error: analyticsError } = useSWR( workspaceSlug ? ANALYTICS(workspaceSlug.toString(), params) : null, workspaceSlug ? () => analyticsService.getAnalytics(workspaceSlug.toString(), params) : null ); const { workspaceAnalyticsSidebarCollapsed } = useAppTheme(); const isProjectLevel = projectId ? true : false; return (
); });