Skip to content

Commit

Permalink
fix: ne montre pas 'Non' quand une case à cocher n'est pas cochée (#1848
Browse files Browse the repository at this point in the history
)
  • Loading branch information
arnaudambro authored Feb 1, 2024
1 parent b4e6b6c commit bfebcd2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dashboard/src/components/CustomFieldDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { formatDateTimeWithNameOfDay, formatDateWithNameOfDay } from '../service
const showBoolean = (value) => {
if (value === null) return '';
if (value === undefined) return '';
if (!value) return 'Non';
if (!value) return '';
return 'Oui';
};

Expand Down
35 changes: 22 additions & 13 deletions dashboard/src/components/CustomFieldInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const CustomFieldInput = ({ field, values, handleChange, model, colWidth = null,
<FormGroup>
{!hideLabel && (
<label className="tw-text-sm tw-font-semibold tw-text-gray-600" data-test-id={field.label} htmlFor={id}>
{field.type !== 'boolean' ? field.label : ''}
{field.label}
</label>
)}
{!!['text', 'number'].includes(field.type) && (
Expand Down Expand Up @@ -88,18 +88,27 @@ const CustomFieldInput = ({ field, values, handleChange, model, colWidth = null,
</div>
)}
{!!['boolean'].includes(field.type) && (
<CheckboxContainer>
<label htmlFor={id}>{field.label}</label>
<input
type="checkbox"
id={id}
required={field.required}
name={field.name}
checked={values[field.name]}
onChange={() => handleChange({ target: { value: !values[field.name], name: field.name } })}
disabled={disabled}
/>
</CheckboxContainer>
/*
display: flex;
flex-direction: column;
margin-left: 20px;
width: 80%;
*/
<div className="tw-basis-full tw-p-4">
<label htmlFor={id}>
<input
type="checkbox"
id={id}
required={field.required}
name={field.name}
checked={values[field.name]}
onChange={() => handleChange({ target: { value: !values[field.name], name: field.name } })}
disabled={disabled}
className="tw-mr-2"
/>
{field.label}
</label>
</div>
)}
{!!['yes-no'].includes(field.type) && (
<SelectAsInput
Expand Down

0 comments on commit bfebcd2

Please sign in to comment.