1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

(bug) Fix member date of birth input

This commit is contained in:
Vincent 2023-02-17 10:46:37 +01:00
parent f38050f964
commit a5eba1db11
3 changed files with 10 additions and 2 deletions

View File

@ -64,6 +64,13 @@ export const FormInput = <TFieldValues extends FieldValues, TInputType>({ id, re
}
return num;
}
if (type === 'date') {
const date: Date = new Date(value);
if (Number.isNaN(date) && nullable) {
return null;
}
return date;
}
setCharacterCount(value?.length || 0);
return value;
}
@ -84,7 +91,6 @@ export const FormInput = <TFieldValues extends FieldValues, TInputType>({ id, re
<input id={id} aria-label={ariaLabel}
{...register(id as FieldPath<TFieldValues>, {
...rules,
valueAsDate: type === 'date',
setValueAs: parseValue,
value: defaultValue as FieldPathValue<TFieldValues, FieldPath<TFieldValues>>,
onChange: (e) => { handleChange(e); }

View File

@ -209,7 +209,8 @@ export const UserProfileForm: React.FC<UserProfileFormProps> = ({ action, size,
disabled={isDisabled}
rules={{ required: true }}
formState={formState}
type="date" />
type="date"
nullable />
<FormInput id="profile_attributes.phone"
register={register}
rules={{

View File

@ -139,6 +139,7 @@
}
&.is-incorrect &-field {
border-color: var(--alert);
input:focus { box-shadow: 0 0 0 2px var(--alert); }
.icon {
color: var(--alert);
border-color: var(--alert);