import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; import { useForm } from "react-hook-form"; import useSWR from "swr"; // 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 { useApplication } from "hooks/store"; import { AnalyticsService } from "services/analytics.service"; import { IAnalyticsParams } from "@plane/types"; 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 router = useRouter(); const { workspaceSlug, projectId } = router.query; 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 { theme: themeStore } = useApplication(); const isProjectLevel = projectId ? true : false; return (
); });