Skip to content
Snippets Groups Projects
Commit 285d8c84 authored by Tore.Brede's avatar Tore.Brede
Browse files

Merge branch 'GREG-136_default_role_date_values' into 'master'

GREG-136: Adding today as default date

See merge request !190
parents 87ca8a5c 70862499
No related branches found
No related tags found
1 merge request!190GREG-136: Adding today as default date
Pipeline #102931 passed
......@@ -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
......
......@@ -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="____-__-__"
......
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment