diff --git a/frontend/src/routes/sponsor/register/formData.ts b/frontend/src/routes/sponsor/register/formData.ts index 8e96d7a625f1da93f7e34360939c4ccb0f267cb9..6700f9574e73514c604cc0170222b31937922ade 100644 --- a/frontend/src/routes/sponsor/register/formData.ts +++ b/frontend/src/routes/sponsor/register/formData.ts @@ -2,8 +2,8 @@ export type RegisterFormData = { first_name?: string last_name?: string role_type?: string - role_start?: Date - role_end?: Date + role_start: Date + role_end: Date contact_person_unit?: string comment?: string ou_id?: number diff --git a/frontend/src/routes/sponsor/register/stepPersonForm.tsx b/frontend/src/routes/sponsor/register/stepPersonForm.tsx index c4427e9dfd4a0b0665b0df8e7e89afc5517d44f9..e796fa3361a2fffa1e6843e4237c7e84ea017bf0 100644 --- a/frontend/src/routes/sponsor/register/stepPersonForm.tsx +++ b/frontend/src/routes/sponsor/register/stepPersonForm.tsx @@ -46,6 +46,7 @@ const StepPersonForm = forwardRef( ) const roleTypes = useRoleTypes() const { displayContactAtUnit, displayComment } = useContext(FeatureContext) + const today: Date = new Date() const roleTypeSort = () => (a: RoleTypeData, b: RoleTypeData) => { if (i18n.language === 'en') { @@ -204,6 +205,7 @@ const StepPersonForm = forwardRef( name="role_start" control={control} rules={{ validate: validateStartDateBeforeEndDate }} + defaultValue={today} render={({ field }) => ( <DatePicker mask="____-__-__" @@ -225,6 +227,7 @@ const StepPersonForm = forwardRef( <Controller name="role_end" control={control} + defaultValue={today} render={({ field }) => ( <DatePicker mask="____-__-__" diff --git a/frontend/src/routes/sponsor/register/stepRegistration.tsx b/frontend/src/routes/sponsor/register/stepRegistration.tsx index 3d274b468bd51214b7d2d37d47713ff633e3a21d..e7592ede61751bcfb9045c94864b1d1e6cea116e 100644 --- a/frontend/src/routes/sponsor/register/stepRegistration.tsx +++ b/frontend/src/routes/sponsor/register/stepRegistration.tsx @@ -33,8 +33,9 @@ export default function StepRegistration() { first_name: undefined, last_name: undefined, role_type: undefined, - role_start: undefined, - role_end: undefined, + // Having role_start and role_end to be nullable caused problems when specifying a default value, so instead having them as non-null and use today as the default date here + role_start: new Date(), + role_end: new Date(), comment: undefined, ou_id: undefined, email: undefined,