diff --git a/packages/berlin/src/pages/Register.tsx b/packages/berlin/src/pages/Register.tsx index 65edc8c0..13400b07 100644 --- a/packages/berlin/src/pages/Register.tsx +++ b/packages/berlin/src/pages/Register.tsx @@ -688,6 +688,18 @@ function FormField({ value={value} /> ); + case 'NUMBER': + return ( + + ); default: return null; } @@ -821,6 +833,52 @@ function TextAreaInput(props: { ); } +function NumberInput(props: { + id: string; + name: string; + required: boolean | null; + disabled: boolean; + register: UseFormRegister>; + errors: FieldErrors>; + value: string; +}) { + return ( + + { + if (!props.required) { + return true; + } + + const v = z.coerce + .number() + .int('Value has to be an integer') + .min(0, 'Value must be positive') + .safeParse(value); + + if (v.success) { + return true; + } + + return v.error.errors[0].message; + }, + })} + onChange={(event) => { + props.register(props.id, { + value: event.target.value, + }); + }} + /> + {props.errors?.[props.id] && {props.errors?.[props.id]?.message}} + + ); +} + function SelectInput(props: { id: string; name: string;