import { styled } from '@mui/material'; import { FeatureLifecycleStageIcon } from 'component/common/FeatureLifecycle/FeatureLifecycleStageIcon'; import { useProjectStatus } from 'hooks/api/getters/useProjectStatus/useProjectStatus'; import useLoading from 'hooks/useLoading'; import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; import type { FC } from 'react'; import { PrettifyLargeNumber } from 'component/common/PrettifyLargeNumber/PrettifyLargeNumber'; import type { ProjectStatusSchemaLifecycleSummary } from 'openapi'; import { HtmlTooltip } from 'component/common/HtmlTooltip/HtmlTooltip'; import { lifecycleMessages } from './LifecycleMessages'; import InfoIcon from '@mui/icons-material/Info'; import { useUiFlag } from 'hooks/useUiFlag'; import { getFeatureLifecycleName } from 'component/common/FeatureLifecycle/getFeatureLifecycleName'; const LifecycleBoxContent = styled('div')(({ theme }) => ({ padding: theme.spacing(2), gap: theme.spacing(2), minHeight: '100%', display: 'flex', flexFlow: 'column', justifyContent: 'space-between', transition: 'all 200ms', borderRadius: theme.shape.borderRadiusExtraLarge, border: `2px solid ${theme.palette.divider}`, '&:focus-visible': { outline: 'none', borderColor: theme.palette.primary.main, }, '&:hover': { backgroundColor: theme.palette.table.rowHover, }, })); const LifecycleBoxTooltip: FC<{ text: string }> = ({ text }) => { const Container = styled('span')(({ theme }) => ({ display: 'flex', alignItems: 'flex-start', gap: theme.spacing(1), fontSize: theme.typography.body1.fontSize, padding: theme.spacing(1), })); return (

{text}

); }; const LifecycleBox = ({ children, tooltipText, }: { children: React.ReactNode; tooltipText: string; }) => { return (
  • } > {children}
  • ); }; const LifecycleList = styled('ul')(({ theme }) => ({ display: 'grid', listStyle: 'none', gridTemplateColumns: 'repeat(auto-fit, minmax(180px, 1fr))', gap: theme.spacing(1), justifyContent: 'center', padding: 0, flex: 'auto', margin: 0, })); const Counter = styled('span')({ display: 'flex', alignItems: 'center', justifyContent: 'space-between', }); const BigText = styled('span')(({ theme }) => ({ fontSize: `calc(2 * ${theme.typography.body1.fontSize})`, })); const Stats = styled('dl')(({ theme }) => ({ margin: 0, fontSize: theme.typography.body2.fontSize, '& dd': { margin: 0, fontWeight: 'bold', }, })); const StyledStageTitle = styled('span')(({ theme }) => ({ fontSize: theme.typography.body2.fontSize, })); const NoData = styled('span')({ fontWeight: 'normal', }); const AverageDaysStat: FC<{ averageDays?: number | null }> = ({ averageDays, }) => { const Content = () => { if (averageDays === null || averageDays === undefined) { return No data; } if (averageDays < 1) { return 'less than a day'; } return `${averageDays} days`; }; return (
    Avg. time in stage
    ); }; const BigNumber: FC<{ value?: number }> = ({ value }) => { return ( ); }; export const ProjectLifecycleSummary = () => { const projectId = useRequiredPathParam('projectId'); const { data, loading } = useProjectStatus(projectId); const isLifecycleImprovementsEnabled = useUiFlag('lifecycleImprovements'); const loadingRef = useLoading( loading, '[data-loading-project-lifecycle-summary=true]', ); const flagWord = (stage: keyof ProjectStatusSchemaLifecycleSummary) => { const hasOneFlag = data?.lifecycleSummary[stage].currentFlags === 1; if (hasOneFlag) { return isLifecycleImprovementsEnabled ? 'Flag' : 'flag'; } return isLifecycleImprovementsEnabled ? 'Flags' : 'flags'; }; const stageName = (stage: keyof ProjectStatusSchemaLifecycleSummary) => { if (!isLifecycleImprovementsEnabled) { return `${flagWord('initial')} in ${stage}`; } const lifecycleStageName = stage === 'preLive' ? 'pre-live' : stage; return ( {flagWord(stage)} in{' '} {getFeatureLifecycleName(lifecycleStageName)} stage ); }; return (

    {stageName('initial')}

    {stageName('preLive')}

    {stageName('live')}

    {stageName('completed')}

    {stageName('archived')}

    Last 30 days
    {data?.lifecycleSummary.archived.last30Days ?? 0} flags archived
    ); };