Skip to content

Commit

Permalink
Merge pull request #102 from bcgov/feature/assistance
Browse files Browse the repository at this point in the history
Add assistance flow for submission intake
  • Loading branch information
kyle1morel authored Jul 2, 2024
2 parents 25ef295 + 72a8fa2 commit 7165b03
Show file tree
Hide file tree
Showing 6 changed files with 270 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<script setup lang="ts">
import { Message } from '@/lib/primevue';
import { RouteName } from '@/utils/enums/application';
// Props
type Props = {
assignedActivityId: string;
};
const props = withDefaults(defineProps<Props>(), {});
</script>

<template>
<div>
<h2>Confirmation of Submission</h2>
<Message
class="border-none"
severity="success"
:closable="false"
>
Your enquiry has been successfully submitted.
</Message>
<h3>Confirmation ID: {{ props.assignedActivityId }}</h3>
<div>
A Housing Navigator will review your submission and contact you. Please check your email for the confirmation
email and keep the confirmation ID for future reference.
</div>
<div class="mt-4"><router-link :to="{ name: RouteName.HOME }">Go to Homepage</router-link></div>
</div>
</template>
23 changes: 6 additions & 17 deletions frontend/src/components/housing/enquiry/EnquiryIntakeForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { object, string } from 'yup';
import { Dropdown, InputMask, RadioList, InputText, StepperNavigation, TextArea } from '@/components/form';
import CollectionDisclaimer from '@/components/housing/CollectionDisclaimer.vue';
import { Button, Card, Divider, Message, useConfirm, useToast } from '@/lib/primevue';
import EnquiryIntakeConfirmation from '@/components/housing/enquiry/EnquiryIntakeConfirmation.vue';
import { Button, Card, Divider, useConfirm, useToast } from '@/lib/primevue';
import { enquiryService, submissionService } from '@/services';
import { useConfigStore } from '@/store';
import { YES_NO_LIST } from '@/utils/constants/application';
Expand Down Expand Up @@ -442,22 +443,10 @@ async function emailConfirmation(activityId: string) {
</div>
</Form>
</div>
<div v-else>
<h2>Confirmation of Submission</h2>
<Message
class="border-none"
severity="success"
:closable="false"
>
Your enquiry has been successfully submitted.
</Message>
<h3>Confirmation ID: {{ assignedActivityId }}</h3>
<div>
A Housing Navigator will review your submission and contact you. Please check your email for the confirmation
email and keep the confirmation ID for future reference.
</div>
<div class="mt-4"><router-link :to="{ name: RouteName.HOME }">Go to Homepage</router-link></div>
</div>
<EnquiryIntakeConfirmation
v-else
:assigned-activity-id="assignedActivityId"
/>
</template>

<style scoped lang="scss">
Expand Down
176 changes: 176 additions & 0 deletions frontend/src/components/housing/submission/SubmissionAssistance.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<script setup lang="ts">
import { Button, useConfirm, useToast } from '@/lib/primevue';
import { ref } from 'vue';
import { enquiryService } from '@/services';
import { BasicResponse } from '@/utils/enums/application';
import { IntakeFormCategory } from '@/utils/enums/housing';
import type { Ref } from 'vue';
// Props
type Prop = {
formErrors: Record<string, string | undefined>;
formValues: { [key: string]: string };
};
const props = withDefaults(defineProps<Prop>(), {});
// State
const showTab: Ref<boolean> = ref(true);
// Actions
const confirm = useConfirm();
const toast = useToast();
const checkApplicantValuesValid = (
values: { [key: string]: string },
errors: Record<string, string | undefined>
): boolean => {
// Check applicant section is filled
let applicant = values?.[IntakeFormCategory.APPLICANT];
if (Object.values(applicant).some((x) => !x)) {
return false;
}
// Check applicant section is valid
let isValid = true;
const errorList = Object.keys(errors);
for (const error of errorList) {
if (error.includes(IntakeFormCategory.APPLICANT)) {
isValid = false;
break;
}
}
return isValid;
};
const confirmSubmit = (data: any) => {
confirm.require({
message: 'Are you sure you wish to submit this form? Please review the form before submitting.',
header: 'Please confirm submission',
acceptLabel: 'Confirm',
rejectLabel: 'Cancel',
accept: () => onSubmit(data)
});
};
const emit = defineEmits(['onSubmitAssistance']);
const onSubmit = async (values: any) => {
try {
const formattedData = Object.assign(
{
basic: {
applyForPermitConnect: BasicResponse.NO,
enquiryDescription: 'Assistance requested',
isRelated: BasicResponse.NO
},
submit: true
},
{ applicant: values?.[IntakeFormCategory.APPLICANT] }
);
const enquiryResponse = await enquiryService.createDraft(formattedData);
if (enquiryResponse.data.activityId) {
toast.success('Form saved');
emit('onSubmitAssistance', enquiryResponse.data.activityId);
} else {
toast.error('Failed to submit enquiry');
}
} catch (e: any) {
toast.error('Failed to save enquiry', e);
}
};
</script>

<template>
<Teleport to="#app">
<div :class="{ 'teleport-container': true, '--open': showTab }">
<div
class="assistance-tab pb-3 pt-3 pr-1 pl-1"
@click="showTab = !showTab"
>
<div class="tab-text">Assistance</div>
<font-awesome-icon
class="-rotate-90 mt-2"
icon="fa-solid fa-circle-question"
/>
</div>
<div class="assistance-modal">
<div class="font-bold mb-3">Need assistance with the form?</div>
<div>
Are you unable to complete this form and need assistance? Please follow the instructions below. You will be
contacted by a housing navigator.
</div>
<ol class="pl-3">
<li class="mb-1">
Make sure the
<span class="font-bold">'Primary Contact'</span>
section under
<span class="font-bold">'Contact Information'</span>
tab is filled out.
</li>
<li class="mb-1">Try to fill out the form as much as you can.</li>
<li class="mb-1">Click "Get assistance" below to submit the form.</li>
</ol>
<div class="flex justify-content-center">
<Button
label="Get assistance"
:disabled="!checkApplicantValuesValid(props.formValues, props.formErrors)"
@click="() => confirmSubmit(props.formValues)"
/>
</div>
</div>
</div>
</Teleport>
</template>

<style scoped lang="scss">
.teleport-container {
position: fixed;
right: 0%;
bottom: 0%;
z-index: 5;
translate: 0rem;
transition: all 0.75s ease-in;
&.--open {
translate: 20rem;
transition: all 0.75s ease-out;
}
}
.assistance-modal {
overflow: hidden;
position: relative;
bottom: 0rem;
right: 0rem;
padding: 1rem;
background-color: white;
border-style: solid;
border-color: #fdb913;
border-width: 3px;
width: 20rem;
}
.assistance-tab {
cursor: pointer;
position: absolute;
top: 0rem;
transform: translate(-100%, 0%);
writing-mode: vertical-lr;
background-color: #fdb913;
border-top-left-radius: 0.5rem;
border-bottom-left-radius: 0.5rem;
z-index: 10;
color: white;
display: flex;
.tab-text {
transform: rotate(180deg);
}
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<script setup lang="ts">
import { Message } from '@/lib/primevue';
import { RouteName } from '@/utils/enums/application';
// Props
type Props = {
assignedActivityId: string;
};
const props = withDefaults(defineProps<Props>(), {});
</script>

<template>
<div>
<h2>Confirmation of Submission</h2>
<Message
class="border-none"
severity="success"
:closable="false"
>
Your application has been successfully submitted.
</Message>
<h3>Confirmation ID: {{ props.assignedActivityId }}</h3>
<div>
Your submission will be reviewed by a Housing Navigator. You may be contacted if needed. Please check your email
for the confirmation email and keep the confirmation ID for future reference.
</div>
<div class="mt-4"><router-link :to="{ name: RouteName.HOME }">Go to Homepage</router-link></div>
</div>
</template>
42 changes: 24 additions & 18 deletions frontend/src/components/housing/submission/SubmissionIntakeForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import {
TextArea
} from '@/components/form';
import CollectionDisclaimer from '@/components/housing/CollectionDisclaimer.vue';
import EnquiryIntakeConfirmation from '@/components/housing/enquiry/EnquiryIntakeConfirmation.vue';
import SubmissionAssistance from '@/components/housing/submission/SubmissionAssistance.vue';
import SubmissionIntakeConfirmation from '@/components/housing/submission/SubmissionIntakeConfirmation.vue';
import { submissionIntakeSchema } from '@/components/housing/submission/SubmissionIntakeSchema';
import {
Accordion,
Expand Down Expand Up @@ -83,6 +86,7 @@ const { getConfig } = storeToRefs(useConfigStore());
const activeStep: Ref<number> = ref(0);
const addressGeocoderOptions: Ref<Array<any>> = ref([]);
const assignedActivityId: Ref<string | undefined> = ref(undefined);
const assistanceAssignedActivityId: Ref<string | undefined> = ref(undefined);
const editable: Ref<boolean> = ref(true);
const formRef: Ref<InstanceType<typeof Form> | null> = ref(null);
const geomarkAccordionIndex: Ref<number | undefined> = ref(undefined);
Expand Down Expand Up @@ -241,6 +245,10 @@ async function onSubmit(data: any) {
}
}
async function onSubmitAssistance(activityId: string) {
assistanceAssignedActivityId.value = activityId;
}
async function emailConfirmation(activityId: string) {
const configCC = getConfig.value.ches?.submission?.cc;
const body = confirmationTemplate({
Expand Down Expand Up @@ -344,7 +352,7 @@ onBeforeMount(async () => {
</script>

<template>
<div v-if="!assignedActivityId">
<div v-if="!assignedActivityId && !assistanceAssignedActivityId">
<BackButton
:confirm-leave="true"
confirm-message="Are you sure you want to leave this page?
Expand All @@ -356,14 +364,20 @@ onBeforeMount(async () => {
<Form
v-if="initialFormValues"
id="form"
v-slot="{ setFieldValue, values }"
v-slot="{ setFieldValue, errors, values }"
ref="formRef"
:initial-values="initialFormValues"
:validation-schema="submissionIntakeSchema"
@invalid-submit="(e) => onInvalidSubmit(e)"
@submit="confirmSubmit"
@change="formUpdated = true"
>
<SubmissionAssistance
:form-errors="errors"
:form-values="values"
@on-submit-assistance="onSubmitAssistance"
/>

<input
type="hidden"
name="submissionId"
Expand Down Expand Up @@ -1504,22 +1518,14 @@ onBeforeMount(async () => {
</div>
</Form>
</div>
<div v-else>
<h2>Confirmation of Submission</h2>
<Message
class="border-none"
severity="success"
:closable="false"
>
Your application has been successfully submitted.
</Message>
<h3>Confirmation ID: {{ assignedActivityId }}</h3>
<div>
Your submission will be reviewed by a Housing Navigator. You may be contacted if needed. Please check your email
for the confirmation email and keep the confirmation ID for future reference.
</div>
<div class="mt-4"><router-link :to="{ name: RouteName.HOME }">Go to Homepage</router-link></div>
</div>
<SubmissionIntakeConfirmation
v-else-if="assignedActivityId"
:assigned-activity-id="assignedActivityId"
/>
<EnquiryIntakeConfirmation
v-else-if="assistanceAssignedActivityId"
:assigned-activity-id="assistanceAssignedActivityId"
/>
</template>

<style scoped lang="scss">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ const wrapperSettings = () => ({
stubs: {
RouterLink: RouterLinkStub,
'font-awesome-icon': true,
Map: true
Map: true,
SubmissionAssistance: true
},
directives: {
Tooltip: Tooltip
Expand Down

0 comments on commit 7165b03

Please sign in to comment.