import React, { Fragment, useState } from "react"; import { useRouter } from "next/router"; import useSWR from "swr"; // react-hook-form import { useForm } from "react-hook-form"; // headless ui import { Tab } from "@headlessui/react"; // services import analyticsService from "services/analytics.service"; // components import { CustomAnalytics, ScopeAndDemand } from "components/analytics"; // icons import { ArrowsPointingInIcon, ArrowsPointingOutIcon, XMarkIcon, } from "@heroicons/react/24/outline"; // types import { IAnalyticsParams } from "types"; // fetch-keys import { ANALYTICS } from "constants/fetch-keys"; type Props = { isOpen: boolean; onClose: () => void; }; const defaultValues: IAnalyticsParams = { x_axis: "priority", y_axis: "issue_count", segment: null, project: null, }; const tabsList = ["Scope and Demand", "Custom Analytics"]; export const AnalyticsProjectModal: React.FC = ({ isOpen, onClose }) => { const [fullScreen, setFullScreen] = useState(false); const router = useRouter(); const { workspaceSlug, projectId, cycleId, moduleId } = 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"), cycle: cycleId ? cycleId.toString() : null, module: moduleId ? moduleId.toString() : null, }; const { data: analytics, error: analyticsError } = useSWR( workspaceSlug ? ANALYTICS(workspaceSlug.toString(), params) : null, workspaceSlug ? () => analyticsService.getAnalytics(workspaceSlug.toString(), params) : null ); const handleClose = () => { onClose(); }; return (

Project Analytics

{tabsList.map((tab) => ( `rounded-3xl border border-brand-base px-4 py-2 text-xs hover:bg-brand-surface-2 ${ selected ? "bg-brand-surface-2" : "" }` } > {tab} ))}
); };