"use client"; import React, { Fragment } from "react"; import { observer } from "mobx-react"; import { useSearchParams } from "next/navigation"; import { Tab } from "@headlessui/react"; // components import { CustomAnalytics, ScopeAndDemand } from "@/components/analytics"; import { PageHead } from "@/components/core"; import { EmptyState } from "@/components/empty-state"; // constants import { ANALYTICS_TABS } from "@/constants/analytics"; import { EmptyStateType } from "@/constants/empty-state"; // hooks import { useCommandPalette, useEventTracker, useProject, useWorkspace } from "@/hooks/store"; const AnalyticsPage = observer(() => { const searchParams = useSearchParams(); const analytics_tab = searchParams.get("analytics_tab"); // store hooks const { toggleCreateProjectModal } = useCommandPalette(); const { setTrackElement } = useEventTracker(); const { workspaceProjectIds, loader } = useProject(); const { currentWorkspace } = useWorkspace(); // derived values const pageTitle = currentWorkspace?.name ? `${currentWorkspace?.name} - Analytics` : undefined; // TODO: refactor loader implementation return ( <> {workspaceProjectIds && ( <> {workspaceProjectIds.length > 0 || loader ? (
{ANALYTICS_TABS.map((tab) => ( {({ selected }) => ( )} ))}
) : ( { setTrackElement("Analytics empty state"); toggleCreateProjectModal(true); }} /> )} )} ); }); export default AnalyticsPage;