Skip to content

Commit

Permalink
refactor(app): refactor ODD protocol card copy when run data is not "…
Browse files Browse the repository at this point in the history
…ok" (#17261)

Closes RQA-3851

When protocol cards have not ok run data, we can't retrieve the completedAt timestamp, and the fallback has been the current date, which is confusing copy. After speaking with Design, the plan is to remove copy if we can't retrieve the completedAt timestamp.
  • Loading branch information
mjhuff authored Jan 15, 2025
1 parent 061ab89 commit 453410e
Showing 1 changed file with 16 additions and 12 deletions.
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

0 comments on commit 453410e

Please sign in to comment.