Skip to content

Commit

Permalink
Populate empty values for contactless section in new contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenhand committed Dec 12, 2024
1 parent a283767 commit f6e9c5c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
22 changes: 20 additions & 2 deletions functions/hrm/prepopulateForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ enum FormInputType {

type FormItemDefinition = {
name: string;
unknownOption: string;
options: { value: string }[];
unknownOption?: string;
options?: { value: string }[];
initialChecked?: boolean;
initializeWithCurrent?: boolean;
} & (
Expand Down Expand Up @@ -347,6 +347,24 @@ const populateInitialValues = async (contact: HrmContact, formDefinitionRootUrl:
rawJson[formItemDefinition.name] = getInitialValue(formItemDefinition);
}
}
const helplineInformation = await loadConfigJson(formDefinitionRootUrl, 'HelplineInformation');
const defaultHelplineOption = (
helplineInformation.helplines.find((helpline: any) => helpline.default) ||
helplineInformation.helplines[0]
).value;
Object.assign(contact.rawJson.contactlessTask, {
date: getInitialValue({
type: FormInputType.DateInput,
initializeWithCurrent: true,
name: 'date',
}),
time: getInitialValue({
type: FormInputType.TimeInput,
initializeWithCurrent: true,
name: 'time',
}),
helpline: defaultHelplineOption,
});
};

const populateContactSection = async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const BLANK_CONTACT: HrmContact = {
date: '',
time: '',
createdOnBehalfOf: '',
helpline: '',
},
categories: {},
},
Expand Down

0 comments on commit f6e9c5c

Please sign in to comment.