Skip to content

Commit b468b53

Browse files
authored
checkbox output is bound to Yes/No value (#11316)
1 parent 79ce0ee commit b468b53

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

packages/client/src/v2-events/features/events/registered-fields/Checkbox.stories.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ export const UncheckedCheckboxShouldNotAppearOnReview: StoryObj<
131131

132132
await canvas.findByText(/Checkbox review?/)
133133

134-
await expect(canvas.queryByTestId('No recommender')).not.toBeInTheDocument()
134+
await expect(await canvas.findByText('No recommender')).toBeInTheDocument()
135+
await expect(
136+
(await canvas.findByTestId('row-value-recommender.none')).textContent
137+
).toEqual('No')
135138
}
136139
}

packages/client/src/v2-events/features/events/registered-fields/Checkbox.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import React from 'react'
1212
import { useIntl } from 'react-intl'
1313
import { Checkbox as CheckboxComponent } from '@opencrvs/components'
1414
import { FieldPropsWithoutReferenceValue } from '@opencrvs/commons/client'
15+
import { buttonMessages } from '@client/i18n/messages'
1516

1617
function CheckboxInput({
1718
label,
@@ -48,14 +49,10 @@ function CheckboxOutput({
4849
value?: boolean
4950
required?: boolean
5051
}) {
51-
// If a checkbox is required, we always show it
52-
if (required) {
53-
// We explicity check for boolean true, so that e.g. string values are not interpreted as true.
54-
return value === true ? 'Yes' : 'No'
55-
}
56-
57-
// If a checkbox is not required, we only show it if it is true
58-
return value === true ? 'Yes' : null
52+
const intl = useIntl()
53+
return value === true
54+
? intl.formatMessage(buttonMessages.yes)
55+
: intl.formatMessage(buttonMessages.no)
5956
}
6057

6158
export const Checkbox = {

0 commit comments

Comments
 (0)