Skip to content

Commit

Permalink
RadioFormField: changed optionDisplay to optionLabel in RadioFormField
Browse files Browse the repository at this point in the history
  • Loading branch information
xakep8 committed Sep 13, 2024
1 parent d1bc4c8 commit dd57313
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 36 deletions.
25 changes: 15 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Components/ExternalResult/ResultUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export default function UpdateResult(props: any) {
]}
value={state.form.patient_created}
onChange={handleChange}
optionDisplay={(option) => option.label}
optionLabel={(option) => option.label}
optionValue={(option) => option.value}
error={state.errors.patient_created}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Facility/FacilityCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ export const FacilityCreate = (props: FacilityProps) => {
{...field("kasp_empanelled")}
label={`Is this facility ${careConfig.kasp.string} empanelled?`}
options={[true, false]}
optionDisplay={(o) => (o ? "Yes" : "No")}
optionLabel={(o) => (o ? "Yes" : "No")}
optionValue={(o) => String(o)}
/>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Form/FormFields/RadioFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FormFieldBaseProps, useFormFieldPropsResolver } from "./Utils";

type Props<T, V = string> = FormFieldBaseProps<V | null> & {
options: readonly T[];
optionDisplay: (option: T) => React.ReactNode;
optionLabel: (option: T) => React.ReactNode;
optionValue: (option: T) => V;
containerClassName?: string;
unselectLabel?: string;
Expand Down Expand Up @@ -47,7 +47,7 @@ const RadioFormField = <T, V extends string>(props: Props<T, V>) => {
<RadioInput
key={value}
id={`${props.name}-option-${value}`}
label={props.optionDisplay(option)}
label={props.optionLabel(option)}
name={field.name}
value={props.optionValue(option)}
checked={value === field.value}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/LogUpdate/Sections/BloodSugar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const BloodSugar = ({ log, onChange }: LogUpdateSectionProps) => {
label="Frequency"
name="insulin_intake_frequency"
options={INSULIN_INTAKE_FREQUENCY_OPTIONS}
optionDisplay={(c) => t(`INSULIN_INTAKE_FREQUENCY__${c}`)}
optionLabel={(c) => t(`INSULIN_INTAKE_FREQUENCY__${c}`)}
optionValue={(c) => c}
value={log.insulin_intake_frequency}
onChange={(c) =>
Expand Down
12 changes: 6 additions & 6 deletions src/Components/LogUpdate/Sections/NeurologicalMonitoring.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const NeurologicalMonitoring = ({ log, onChange }: LogUpdateSectionProps) => {
<RadioFormField
name="consciousness_level"
options={CONSCIOUSNESS_LEVEL}
optionDisplay={(c) => t(`CONSCIOUSNESS_LEVEL__${c.value}`)}
optionLabel={(c) => t(`CONSCIOUSNESS_LEVEL__${c.value}`)}
optionValue={(c) => c.value}
value={log.consciousness_level}
onChange={(c) =>
Expand Down Expand Up @@ -60,7 +60,7 @@ const NeurologicalMonitoring = ({ log, onChange }: LogUpdateSectionProps) => {
(o) => o.value !== "UNKNOWN",
)}
id={`${d}_reaction`}
optionDisplay={(c) => t(`PUPIL_REACTION__${c.value}`)}
optionLabel={(c) => t(`PUPIL_REACTION__${c.value}`)}
optionValue={(c) => c.value}
name={`${d}_pupil_light_reaction`}
value={log[`${d}_pupil_light_reaction`]}
Expand Down Expand Up @@ -98,7 +98,7 @@ const NeurologicalMonitoring = ({ log, onChange }: LogUpdateSectionProps) => {
<RadioFormField
label={<b>Eye Opening Response</b>}
options={EYE_OPEN_SCALE}
optionDisplay={(c) => c.value + " - " + c.text}
optionLabel={(c) => c.value + " - " + c.text}
optionValue={(c) => `${c.value}`}
name="eye_opening_response"
value={`${log.glasgow_eye_open}`}
Expand All @@ -110,7 +110,7 @@ const NeurologicalMonitoring = ({ log, onChange }: LogUpdateSectionProps) => {
<RadioFormField
label={<b>Verbal Response</b>}
options={VERBAL_RESPONSE_SCALE}
optionDisplay={(c) => c.value + " - " + c.text}
optionLabel={(c) => c.value + " - " + c.text}
optionValue={(c) => `${c.value}`}
name="verbal_response"
value={`${log.glasgow_verbal_response}`}
Expand All @@ -124,7 +124,7 @@ const NeurologicalMonitoring = ({ log, onChange }: LogUpdateSectionProps) => {
<RadioFormField
label={<b>Motor Response</b>}
options={MOTOR_RESPONSE_SCALE}
optionDisplay={(c) => c.value + " - " + c.text}
optionLabel={(c) => c.value + " - " + c.text}
optionValue={(c) => `${c.value}`}
name="motor_response"
value={`${log.glasgow_motor_response}`}
Expand Down Expand Up @@ -164,7 +164,7 @@ const NeurologicalMonitoring = ({ log, onChange }: LogUpdateSectionProps) => {
</span>
}
options={LIMB_RESPONSE_OPTIONS.filter((o) => o.value !== "UNKNOWN")}
optionDisplay={(c) => t(`LIMB_RESPONSE__${c.value}`)}
optionLabel={(c) => t(`LIMB_RESPONSE__${c.value}`)}
optionValue={(c) => c.value}
name={key}
value={log[key]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const OxygenRespiratorySupport = ({ log, onChange }: LogUpdateSectionProps) => {
<RadioFormField
label={<h4>Oxygen Modality</h4>}
options={OXYGEN_MODALITY_OPTIONS}
optionDisplay={(c) => t(`OXYGEN_MODALITY__${c.value}`)}
optionLabel={(c) => t(`OXYGEN_MODALITY__${c.value}`)}
optionValue={(c) => c.value}
name="ventilator_oxygen_modality"
value={log.ventilator_oxygen_modality}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const RespiratorySupport = ({ log, onChange }: LogUpdateSectionProps) => {
label="Bilateral Air Entry"
labelClassName="text-lg sm:font-bold"
options={[true, false]}
optionDisplay={(c) => (c ? "Yes" : "No")}
optionLabel={(c) => (c ? "Yes" : "No")}
optionValue={(c) => JSON.stringify(c)}
name="bilateral_air_entry"
value={
Expand Down Expand Up @@ -90,7 +90,7 @@ const RespiratorySupport = ({ log, onChange }: LogUpdateSectionProps) => {
<RadioFormField
label={<h4>Respiratory Support</h4>}
options={RESPIRATORY_SUPPORT}
optionDisplay={(c) => t(`RESPIRATORY_SUPPORT__${c.value}`)}
optionLabel={(c) => t(`RESPIRATORY_SUPPORT__${c.value}`)}
optionValue={(c) => c.value}
name="respiratory_support"
value={log.ventilator_interface}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/LogUpdate/Sections/Vitals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const Vitals = ({ log, onChange }: LogUpdateSectionProps) => {
label={t("heartbeat_rhythm")}
name="heartbeat-rythm"
options={HEARTBEAT_RHYTHM_CHOICES}
optionDisplay={(c) => t(`HEARTBEAT_RHYTHM__${c}`)}
optionLabel={(c) => t(`HEARTBEAT_RHYTHM__${c}`)}
optionValue={(c) => c}
value={log.rhythm}
onChange={(c) => onChange({ rhythm: c.value ?? undefined })}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Patient/DailyRounds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ export const DailyRounds = (props: any) => {
label: t(`CONSCIOUSNESS_LEVEL__${level.value}`),
value: level.value,
}))}
optionDisplay={(option) => option.label}
optionLabel={(option) => option.label}
optionValue={(option) => option.value}
unselectLabel="Unknown"
layout="vertical"
Expand Down
10 changes: 5 additions & 5 deletions src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
{ label: "Yes", value: "true" },
{ label: "No", value: "false" },
]}
optionDisplay={(option) => option.label}
optionLabel={(option) => option.label}
optionValue={(option) => option.value}
/>
</div>
Expand Down Expand Up @@ -1501,7 +1501,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
{ label: "Yes", value: "true" },
{ label: "No", value: "false" },
]}
optionDisplay={(option) => option.label}
optionLabel={(option) => option.label}
optionValue={(option) => option.value}
/>
</CollapseV2>
Expand Down Expand Up @@ -1781,7 +1781,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
{ label: "Yes", value: "true" },
{ label: "No", value: "false" },
]}
optionDisplay={(option) => option.label}
optionLabel={(option) => option.label}
optionValue={(option) => option.value}
/>
</div>
Expand Down Expand Up @@ -1815,7 +1815,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
value: "3",
},
]}
optionDisplay={(option) => option.label}
optionLabel={(option) => option.label}
optionValue={(option) => option.value}
/>
</div>
Expand Down Expand Up @@ -1850,7 +1850,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
{ label: "Yes", value: "true" },
{ label: "No", value: "false" },
]}
optionDisplay={(option) => option.label}
optionLabel={(option) => option.label}
optionValue={(option) => option.value}
/>
<CollapseV2
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Resource/ResourceCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export default function ResourceCreate(props: resourceProps) {
label={t("is_this_an_emergency")}
name="emergency"
options={[true, false]}
optionDisplay={(o) => (o ? t("yes") : t("no"))}
optionLabel={(o) => (o ? t("yes") : t("no"))}
optionValue={(o) => String(o)}
value={state.form.emergency}
onChange={handleChange}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Resource/ResourceDetailsUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export const ResourceDetailsUpdate = (props: resourceProps) => {
onChange={handleChange}
label={"Is this an emergency?"}
options={[true, false]}
optionDisplay={(o) => (o ? "Yes" : "No")}
optionLabel={(o) => (o ? "Yes" : "No")}
optionValue={(o) => String(o)}
value={String(state.form.emergency)}
error={state.errors.emergency}
Expand Down
6 changes: 3 additions & 3 deletions src/Components/Shifting/ShiftDetailsUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ export const ShiftDetailsUpdate = (props: patientShiftProps) => {
{ label: t("yes"), value: "true" },
{ label: t("no"), value: "false" },
]}
optionDisplay={(option) => option.label}
optionLabel={(option) => option.label}
optionValue={(option) => option.value}
/>

Expand All @@ -434,7 +434,7 @@ export const ShiftDetailsUpdate = (props: patientShiftProps) => {
{ label: t("no"), value: "false" },
]}
optionValue={(option) => option.value}
optionDisplay={(option) => option.label}
optionLabel={(option) => option.label}
onChange={handleFormFieldChange}
/>
)}
Expand All @@ -448,7 +448,7 @@ export const ShiftDetailsUpdate = (props: patientShiftProps) => {
{ label: t("no"), value: "false" },
]}
optionValue={(option) => option.value}
optionDisplay={(option) => option.label}
optionLabel={(option) => option.label}
onChange={handleFormFieldChange}
/>

Expand Down

0 comments on commit dd57313

Please sign in to comment.