import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; // hooks import { ProjectLogo } from "@/components/project"; import { NETWORK_CHOICES } from "@/constants/project"; import { renderFormattedDate } from "@/helpers/date-time.helper"; import { useCycle, useMember, useModule, useProject } from "@/hooks/store"; // components // helpers // constants export const CustomAnalyticsSidebarHeader = observer(() => { const router = useRouter(); const { projectId, cycleId, moduleId } = router.query; const { getProjectById } = useProject(); const { getCycleById } = useCycle(); const { getModuleById } = useModule(); const { getUserDetails } = useMember(); const cycleDetails = cycleId ? getCycleById(cycleId.toString()) : undefined; const moduleDetails = moduleId ? getModuleById(moduleId.toString()) : undefined; const projectDetails = projectId ? getProjectById(projectId.toString()) : undefined; const cycleOwnerDetails = cycleDetails ? getUserDetails(cycleDetails.owned_by_id) : undefined; const moduleLeadDetails = moduleDetails && moduleDetails.lead_id ? getUserDetails(moduleDetails.lead_id) : undefined; return ( <> {projectId ? ( cycleDetails ? (

Analytics for {cycleDetails.name}

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

Analytics for {moduleDetails.name}

Lead
{moduleLeadDetails && {moduleLeadDetails?.display_name}}
Start Date
{moduleDetails.start_date && moduleDetails.start_date !== "" ? renderFormattedDate(moduleDetails.start_date) : "No start date"}
Target Date
{moduleDetails.target_date && moduleDetails.target_date !== "" ? renderFormattedDate(moduleDetails.target_date) : "No end date"}
) : (
{projectDetails && ( )}

{projectDetails?.name}

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