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

refactor(app): refactor ODD protocol card copy when run data is not "ok" #17261

Merged
merged 1 commit into from
Jan 15, 2025
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
28 changes: 16 additions & 12 deletions app/src/organisms/ODD/RobotDashboard/RecentRunProtocolCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,22 @@ export function ProtocolWithLastRun({
[RUN_STATUS_SUCCEEDED]: t('completed'),
[RUN_STATUS_FAILED]: t('failed'),
}
// TODO(BC, 2023-06-05): see if addSuffix false allow can remove usage of .replace here
const formattedLastRunTime = formatDistance(
// Fallback to current date if completedAt is null, though this should never happen since runs must be completed to appear in dashboard
new Date(runData.completedAt ?? new Date()),
new Date(),
{
addSuffix: true,
const formattedLastRunTime =
runData.completedAt != null
? formatDistance(new Date(runData.completedAt), new Date(), {
addSuffix: true,
}).replace('about ', '')
: null
const buildLastRunCopy = (): string => {
if (formattedLastRunTime != null) {
return i18n.format(
`${terminationTypeMap[runData.status] ?? ''} ${formattedLastRunTime}`,
'capitalize'
)
} else {
return ''
}
).replace('about ', '')
}

return isProtocolFetching || isLookingForHardware ? (
<Skeleton
Expand Down Expand Up @@ -227,10 +234,7 @@ export function ProtocolWithLastRun({
lineHeight={TYPOGRAPHY.lineHeight28}
color={COLORS.grey60}
>
{i18n.format(
`${terminationTypeMap[runData.status] ?? ''} ${formattedLastRunTime}`,
'capitalize'
)}
{buildLastRunCopy()}
</LegacyStyledText>
</Flex>
)
Expand Down
Loading