Skip to content

Commit

Permalink
Merge pull request #209 from bcgov/bug/optional-permit-entries
Browse files Browse the repository at this point in the history
Optional permit entries started and not finished causes error
  • Loading branch information
kyle1morel authored Dec 3, 2024
2 parents 2693cfb + e44ca35 commit cc9b501
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions frontend/src/components/housing/submission/SubmissionIntakeForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ async function onSubmit(data: any) {
]
);
// Remove empty investigate permit objects
const filteredInvestigatePermits = submissionData.investigatePermits.filter(
(x: object) => JSON.stringify(x) !== '{}'
);
submissionData.investigatePermits = filteredInvestigatePermits;
const response = await submissionService.submitDraft({ ...submissionData, draftId });
if (response.data.activityId && response.data.submissionId) {
Expand All @@ -391,23 +398,27 @@ async function onSubmit(data: any) {
}
}
async function emailConfirmation(activityId: string, submissionId: string) {
const configCC = getConfig.value.ches?.submission?.cc;
const body = confirmationTemplateSubmission({
'{{ contactName }}': formRef.value?.values.contacts[0].firstName,
'{{ activityId }}': activityId,
'{{ submissionId }}': submissionId
});
let applicantEmail = formRef.value?.values.contacts[0].email;
let emailData = {
from: configCC,
to: [applicantEmail],
cc: configCC,
subject: 'Confirmation of Submission',
bodyType: 'html',
body: body
};
await submissionService.emailConfirmation(emailData);
async function emailConfirmation(actId: string, subId: string) {
try {
const configCC = getConfig.value.ches?.submission?.cc;
const body = confirmationTemplateSubmission({
'{{ contactName }}': formRef.value?.values.contactFirstName,
'{{ activityId }}': actId,
'{{ submissionId }}': subId
});
let applicantEmail = formRef.value?.values.contactEmail;
let emailData = {
from: configCC,
to: [applicantEmail],
cc: configCC,
subject: 'Confirmation of Submission',
bodyType: 'html',
body: body
};
await submissionService.emailConfirmation(emailData);
} catch (e: any) {
toast.error('Failed to send confirmation email. ', e);
}
}
async function onRegisteredNameInput(e: AutoCompleteCompleteEvent) {
Expand All @@ -419,22 +430,22 @@ async function onRegisteredNameInput(e: AutoCompleteCompleteEvent) {
}
}
function syncFormAndRoute(activityId: string, draftId: string) {
if (draftId) {
function syncFormAndRoute(actId: string, drftId: string) {
if (drftId) {
// Update route query for refreshing
router.replace({
name: RouteName.HOUSING_SUBMISSION_INTAKE,
query: {
draftId: draftId
draftId: drftId
}
});
}
if (activityId) {
if (actId) {
formRef.value?.resetForm({
values: {
...formRef.value?.values,
activityId: activityId
activityId: actId
}
});
}
Expand Down

0 comments on commit cc9b501

Please sign in to comment.