Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: handle edge cases #8719

Merged
merged 5 commits into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { useProjectStatus } from 'hooks/api/getters/useProjectStatus/useProjectS
import useLoading from 'hooks/useLoading';
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import type { FC } from 'react';
import { Link } from 'react-router-dom';

import { PrettifyLargeNumber } from 'component/common/PrettifyLargeNumber/PrettifyLargeNumber';
const LifecycleBox = styled('li')(({ theme }) => ({
padding: theme.spacing(2),
borderRadius: theme.shape.borderRadiusExtraLarge,
Expand All @@ -31,7 +30,7 @@ const Counter = styled('span')({
justifyContent: 'space-between',
});

const BigNumber = styled('span')(({ theme }) => ({
const BigText = styled('span')(({ theme }) => ({
fontSize: `calc(2 * ${theme.typography.body1.fontSize})`,
}));

Expand All @@ -48,10 +47,6 @@ const NoData = styled('span')({
fontWeight: 'normal',
});

const LinkNoUnderline = styled(Link)({
textDecoration: 'none',
});

const AverageDaysStat: FC<{ averageDays?: number | null }> = ({
averageDays,
}) => {
Expand All @@ -60,6 +55,9 @@ const AverageDaysStat: FC<{ averageDays?: number | null }> = ({
return <NoData>No data</NoData>;
}

if (averageDays < 1) {
return 'less than a day';
}
return `${averageDays} days`;
};
return (
Expand All @@ -72,6 +70,18 @@ const AverageDaysStat: FC<{ averageDays?: number | null }> = ({
);
};

const BigNumber: FC<{ value?: number }> = ({ value }) => {
return (
<BigText data-loading-project-lifecycle-summary>
<PrettifyLargeNumber
value={value ?? 0}
threshold={1000}
precision={1}
/>
</BigText>
);
};

export const ProjectLifecycleSummary = () => {
const projectId = useRequiredPathParam('projectId');
const { data, loading } = useProjectStatus(projectId);
Expand All @@ -85,9 +95,9 @@ export const ProjectLifecycleSummary = () => {
<LifecycleBox>
<p>
<Counter>
<BigNumber data-loading-project-lifecycle-summary>
{data?.lifecycleSummary.initial.currentFlags ?? 0}
</BigNumber>
<BigNumber
value={data?.lifecycleSummary.initial.currentFlags}
/>

<FeatureLifecycleStageIcon
aria-hidden='true'
Expand All @@ -103,9 +113,9 @@ export const ProjectLifecycleSummary = () => {
<LifecycleBox>
<p>
<Counter>
<BigNumber data-loading-project-lifecycle-summary>
{data?.lifecycleSummary.preLive.currentFlags ?? 0}
</BigNumber>
<BigNumber
value={data?.lifecycleSummary.preLive.currentFlags}
/>

<FeatureLifecycleStageIcon
aria-hidden='true'
Expand All @@ -121,9 +131,9 @@ export const ProjectLifecycleSummary = () => {
<LifecycleBox>
<p>
<Counter>
<BigNumber data-loading-project-lifecycle-summary>
{data?.lifecycleSummary.live.currentFlags ?? 0}
</BigNumber>
<BigNumber
value={data?.lifecycleSummary.live.currentFlags}
/>

<FeatureLifecycleStageIcon
aria-hidden='true'
Expand All @@ -139,9 +149,11 @@ export const ProjectLifecycleSummary = () => {
<LifecycleBox>
<p>
<Counter>
<BigNumber data-loading-project-lifecycle-summary>
{data?.lifecycleSummary.completed.currentFlags ?? 0}
</BigNumber>
<BigNumber
value={
data?.lifecycleSummary.completed.currentFlags
}
/>

<FeatureLifecycleStageIcon
aria-hidden='true'
Expand All @@ -157,9 +169,9 @@ export const ProjectLifecycleSummary = () => {
<LifecycleBox>
<p>
<Counter>
<BigNumber data-loading-project-lifecycle-summary>
{data?.lifecycleSummary.archived.currentFlags ?? 0}
</BigNumber>
<BigNumber
value={data?.lifecycleSummary.archived.currentFlags}
/>

<FeatureLifecycleStageIcon
aria-hidden='true'
Expand Down
Loading