Skip to content

Commit

Permalink
fix(protocol-designer): fix temperature step form
Browse files Browse the repository at this point in the history
This PR fixes a bug in the temperature step form where a form error is incorrecly returned if a user has not entered a temperature, even if the setTemperature ield is set to false. The error arose from incorrectly parsing the string literals for 'true' / 'false'. Also, this PR fixes the step summary text for deactivating a temperature module

Closes RQA-3947, RQA-3948
  • Loading branch information
ncdiehl11 committed Feb 6, 2025
1 parent 78848e5 commit f619b23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,18 +267,19 @@ export function StepSummary(props: StepSummaryProps): JSX.Element | null {
setTemperature,
targetTemperature,
} = currentStep
const isDeactivating = setTemperature === 'false'
const isSettingTemperature =
setTemperature != null && JSON.parse(String(setTemperature ?? false))
const tempModuleDisplayName =
getModuleDisplayName(modules[tempModuleId]?.model) ?? unknownModule
stepSummaryContent = isDeactivating ? (
stepSummaryContent = isSettingTemperature ? (
<StyledTrans
i18nKey={'protocol_steps:temperature_module.deactivated'}
i18nKey={'protocol_steps:temperature_module.active'}
tagText={`${targetTemperature}${t('application:units.degrees')}`}
values={{ module: tempModuleDisplayName }}
/>
) : (
<StyledTrans
i18nKey={'protocol_steps:temperature_module.active'}
tagText={`${targetTemperature}${t('application:units.degrees')}`}
i18nKey={'protocol_steps:temperature_module.deactivated'}
values={{ module: tempModuleDisplayName }}
/>
)
Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/src/steplist/formLevel/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ export const targetTemperatureRequired = (
fields: HydratedFormData
): FormError | null => {
const { setTemperature, targetTemperature } = fields
return setTemperature && !targetTemperature
return JSON.parse(String(setTemperature ?? false)) && !targetTemperature
? TARGET_TEMPERATURE_REQUIRED
: null
}
Expand Down

0 comments on commit f619b23

Please sign in to comment.