import { useRouter } from "next/router"; import { mutate } from "swr"; // react-hook-form import { Control, UseFormSetValue } from "react-hook-form"; // hooks import useProjects from "hooks/use-projects"; // components import { AnalyticsGraph, AnalyticsSelectBar, AnalyticsSidebar, AnalyticsTable, } from "components/analytics"; // ui import { Loader, PrimaryButton } from "components/ui"; // helpers import { convertResponseToBarGraphData } from "helpers/analytics.helper"; // types import { IAnalyticsParams, IAnalyticsResponse } from "types"; // fetch-keys import { ANALYTICS } from "constants/fetch-keys"; type Props = { analytics: IAnalyticsResponse | undefined; analyticsError: any; params: IAnalyticsParams; control: Control; setValue: UseFormSetValue; fullScreen: boolean; }; export const CustomAnalytics: React.FC = ({ analytics, analyticsError, params, control, setValue, fullScreen, }) => { const router = useRouter(); const { workspaceSlug, projectId } = router.query; const isProjectLevel = projectId ? true : false; const yAxisKey = params.y_axis === "issue_count" ? "count" : "estimate"; const barGraphData = convertResponseToBarGraphData(analytics?.distribution, params); const { projects } = useProjects(); return (
{!analyticsError ? ( analytics ? ( analytics.total > 0 ? (
) : (

No matching issues found. Try changing the parameters.

) ) : ( ) ) : (

There was some error in fetching the data.

{ if (!workspaceSlug) return; mutate(ANALYTICS(workspaceSlug.toString(), params)); }} > Refresh
)}
); };