diff --git a/src/components/Form/Form.tsx b/src/components/Form/Form.tsx index b97d651..7dd2fbf 100644 --- a/src/components/Form/Form.tsx +++ b/src/components/Form/Form.tsx @@ -26,8 +26,8 @@ const FormContext = createContext<{ type TextFormField = { type: 'text' } type TextAreaFormField = { type: 'textarea' } type NumberFormField = { type: 'number' } -type SwitchFormField = { type: 'switch' } -type CheckboxFormField = { type: 'checkbox' } +type SwitchFormField = { type: 'switch'; switchLabel?: string } +type CheckboxFormField = { type: 'checkbox'; checkboxLabel?: string } type DateFormField = { type: 'date' } type DateTimeFormField = { type: 'datetime' } type SelectFormField = { diff --git a/src/components/Form/FormFields.tsx b/src/components/Form/FormFields.tsx index f4a0354..31eaf4d 100644 --- a/src/components/Form/FormFields.tsx +++ b/src/components/Form/FormFields.tsx @@ -64,7 +64,7 @@ function FormFields(_: FormFieldsProps) { disabled={form.isSubmitting || form.isDisabledFromOutside} value={getByPath(form.values, path) as boolean | undefined} onChange={(value) => form.setValue(path, value)} - error={!!getByPath(form.errors, path)} + label={field.switchLabel} /> ) case 'checkbox': @@ -74,6 +74,7 @@ function FormFields(_: FormFieldsProps) { value={getByPath(form.values, path) as boolean | undefined} onChange={(value) => form.setValue(path, value)} error={!!getByPath(form.errors, path)} + label={field.checkboxLabel} /> ) case 'number':