import { useRouter } from "next/router"; import { observer } from "mobx-react-lite"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; // helpers import { renderEmoji } from "helpers/emoji.helper"; import { renderShortDate } from "helpers/date-time.helper"; // constants import { NETWORK_CHOICES } from "constants/project"; export const CustomAnalyticsSidebarHeader = observer(() => { const router = useRouter(); const { workspaceSlug, projectId, cycleId, moduleId } = router.query; const { cycle: cycleStore, module: moduleStore, project: projectStore } = useMobxStore(); const cycleDetails = cycleId ? cycleStore.getCycleById(cycleId.toString()) : undefined; const moduleDetails = moduleId ? moduleStore.getModuleById(moduleId.toString()) : undefined; const projectDetails = workspaceSlug && projectId ? projectStore.getProjectById(workspaceSlug.toString(), projectId.toString()) : undefined; return ( <> {projectId ? ( cycleDetails ? (

Analytics for {cycleDetails.name}

Lead
{cycleDetails.owned_by?.display_name}
Start Date
{cycleDetails.start_date && cycleDetails.start_date !== "" ? renderShortDate(cycleDetails.start_date) : "No start date"}
Target Date
{cycleDetails.end_date && cycleDetails.end_date !== "" ? renderShortDate(cycleDetails.end_date) : "No end date"}
) : moduleDetails ? (

Analytics for {moduleDetails.name}

Lead
{moduleDetails.lead_detail?.display_name}
Start Date
{moduleDetails.start_date && moduleDetails.start_date !== "" ? renderShortDate(moduleDetails.start_date) : "No start date"}
Target Date
{moduleDetails.target_date && moduleDetails.target_date !== "" ? renderShortDate(moduleDetails.target_date) : "No end date"}
) : (
{projectDetails?.emoji ? (
{renderEmoji(projectDetails.emoji)}
) : projectDetails?.icon_prop ? (
{renderEmoji(projectDetails.icon_prop)}
) : ( {projectDetails?.name.charAt(0)} )}

{projectDetails?.name}

Network
{NETWORK_CHOICES.find((n) => n.key === projectDetails?.network)?.label ?? ""}
) ) : null} ); });