mirror of
https://github.com/Unleash/unleash.git
synced 2025-11-10 01:19:53 +01:00
feat: align milestone time formatting (#10903)
This commit is contained in:
parent
b21c101439
commit
a52ee10827
@ -1,12 +1,14 @@
|
|||||||
import { styled } from '@mui/material';
|
import { styled } from '@mui/material';
|
||||||
import HourglassEmptyOutlinedIcon from '@mui/icons-material/HourglassEmptyOutlined';
|
import HourglassEmptyOutlinedIcon from '@mui/icons-material/HourglassEmptyOutlined';
|
||||||
import { isToday, isTomorrow, format, addMinutes } from 'date-fns';
|
import { isToday, isTomorrow, addMinutes } from 'date-fns';
|
||||||
import { useUiFlag } from 'hooks/useUiFlag';
|
import { useUiFlag } from 'hooks/useUiFlag';
|
||||||
|
import { useLocationSettings } from 'hooks/useLocationSettings';
|
||||||
|
import { formatDateHM, formatDateYMD } from 'utils/formatDate';
|
||||||
import type { MilestoneStatus } from './ReleasePlanMilestoneStatus.tsx';
|
import type { MilestoneStatus } from './ReleasePlanMilestoneStatus.tsx';
|
||||||
|
|
||||||
export const formatSmartDate = (date: Date): string => {
|
export const formatSmartDate = (date: Date, locale: string): string => {
|
||||||
const startTime = format(date, 'HH:mm');
|
const startTime = formatDateHM(date, locale);
|
||||||
const endTime = format(addMinutes(date, 2), 'HH:mm');
|
const endTime = formatDateHM(addMinutes(date, 2), locale);
|
||||||
const timeRange = `between ${startTime} - ${endTime}`;
|
const timeRange = `between ${startTime} - ${endTime}`;
|
||||||
|
|
||||||
if (isToday(date)) {
|
if (isToday(date)) {
|
||||||
@ -16,8 +18,7 @@ export const formatSmartDate = (date: Date): string => {
|
|||||||
return `tomorrow ${timeRange}`;
|
return `tomorrow ${timeRange}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For other dates, show full date with time range
|
const dateString = formatDateYMD(date, locale);
|
||||||
const dateString = format(date, 'yyyy-MM-dd');
|
|
||||||
return `${dateString} ${timeRange}`;
|
return `${dateString} ${timeRange}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,12 +47,12 @@ export const MilestoneNextStartTime = ({
|
|||||||
status,
|
status,
|
||||||
}: IMilestoneNextStartTimeProps) => {
|
}: IMilestoneNextStartTimeProps) => {
|
||||||
const milestoneProgressionEnabled = useUiFlag('milestoneProgression');
|
const milestoneProgressionEnabled = useUiFlag('milestoneProgression');
|
||||||
|
const { locationSettings } = useLocationSettings();
|
||||||
|
|
||||||
if (!milestoneProgressionEnabled) {
|
if (!milestoneProgressionEnabled) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only show for not-started milestones with scheduledAt
|
|
||||||
if (status.type !== 'not-started' || !status.scheduledAt) {
|
if (status.type !== 'not-started' || !status.scheduledAt) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -63,7 +64,7 @@ export const MilestoneNextStartTime = ({
|
|||||||
return (
|
return (
|
||||||
<StyledTimeContainer>
|
<StyledTimeContainer>
|
||||||
<StyledHourglassIcon />
|
<StyledHourglassIcon />
|
||||||
{`Starting ${formatSmartDate(projectedStartTime)}`}
|
{`Starting ${formatSmartDate(projectedStartTime, locationSettings.locale)}`}
|
||||||
</StyledTimeContainer>
|
</StyledTimeContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user