From cd2ae860bd7688eac54edb32c07b9599430823e7 Mon Sep 17 00:00:00 2001 From: Kyle Morel Date: Mon, 3 Jun 2024 16:57:38 -0700 Subject: [PATCH] Loading initial values for intake and enquiry --- app/src/controllers/enquiry.ts | 4 +- app/src/services/enquiry.ts | 6 +- .../housing/intake/ShasEnquiryForm.vue | 10 +- .../housing/intake/ShasIntakeForm.vue | 92 ++++++++++++++----- .../layout/DevelopmentRoleOverride.vue | 27 +++--- .../src/components/layout/LoginButton.vue | 25 +++-- frontend/src/types/Permit.ts | 1 + frontend/src/views/housing/HousingView.vue | 4 +- 8 files changed, 116 insertions(+), 53 deletions(-) diff --git a/app/src/controllers/enquiry.ts b/app/src/controllers/enquiry.ts index 577202a66..92b12c166 100644 --- a/app/src/controllers/enquiry.ts +++ b/app/src/controllers/enquiry.ts @@ -119,9 +119,9 @@ const controller = { } }, - getEnquiry: async (req: Request<{ activityId: string }>, res: Response, next: NextFunction) => { + getEnquiry: async (req: Request<{ enquiryId: string }>, res: Response, next: NextFunction) => { try { - const response = await enquiryService.getEnquiry(req.params.activityId); + const response = await enquiryService.getEnquiry(req.params.enquiryId); res.status(200).json(response); } catch (e: unknown) { next(e); diff --git a/app/src/services/enquiry.ts b/app/src/services/enquiry.ts index b785c5e64..893d8393f 100644 --- a/app/src/services/enquiry.ts +++ b/app/src/services/enquiry.ts @@ -63,14 +63,14 @@ const service = { /** * @function getEnquiry * Gets a specific enquiry from the PCNS database - * @param {string} activityId PCNS Activity ID + * @param {string} enquiryId Enquiry ID * @returns {Promise} The result of running the findFirst operation */ - getEnquiry: async (activityId: string) => { + getEnquiry: async (enquiryId: string) => { try { const result = await prisma.enquiry.findFirst({ where: { - activity_id: activityId + enquiry_id: enquiryId } }); diff --git a/frontend/src/components/housing/intake/ShasEnquiryForm.vue b/frontend/src/components/housing/intake/ShasEnquiryForm.vue index 492197817..c5492963d 100644 --- a/frontend/src/components/housing/intake/ShasEnquiryForm.vue +++ b/frontend/src/components/housing/intake/ShasEnquiryForm.vue @@ -178,8 +178,8 @@ async function onSubmit(data: any) { onBeforeMount(async () => { let response; - if (props.activityId) { - response = (await enquiryService.getEnquiry(props.activityId)).data; + if (props.enquiryId) { + response = (await enquiryService.getEnquiry(props.enquiryId)).data; editable.value = response.intakeStatus === INTAKE_STATUS_LIST.DRAFT; } @@ -194,6 +194,12 @@ onBeforeMount(async () => { email: response?.contactEmail, relationshipToProject: response?.contactApplicantRelationship, contactPreference: response?.contactPreference + }, + basic: { + isRelated: response?.isRelated, + relatedActivityId: response?.relatedActivityId, + enquiryDescription: response?.enquiryDescription, + applyForPermitConnect: response?.applyForPermitConnect } }; }); diff --git a/frontend/src/components/housing/intake/ShasIntakeForm.vue b/frontend/src/components/housing/intake/ShasIntakeForm.vue index beb36733c..3cd38eb7a 100644 --- a/frontend/src/components/housing/intake/ShasIntakeForm.vue +++ b/frontend/src/components/housing/intake/ShasIntakeForm.vue @@ -42,9 +42,17 @@ import { YesNo, YesNoUnsure } from '@/utils/constants'; -import { BASIC_RESPONSES, INTAKE_FORM_CATEGORIES, INTAKE_STATUS_LIST, PROJECT_LOCATION } from '@/utils/enums'; +import { + BASIC_RESPONSES, + INTAKE_FORM_CATEGORIES, + INTAKE_STATUS_LIST, + PERMIT_NEEDED, + PERMIT_STATUS, + PROJECT_LOCATION +} from '@/utils/enums'; import type { Ref } from 'vue'; +import type { Permit } from '@/types'; // Props type Props = { @@ -176,9 +184,11 @@ async function onSubmit(data: any) { } onBeforeMount(async () => { - let response; - if (props.submissionId) { + let response, + permits: Array = []; + if (props.activityId && props.submissionId) { response = (await submissionService.getSubmission(props.submissionId)).data; + permits = (await permitService.listPermits(props.activityId)).data; editable.value = response.intakeStatus === INTAKE_STATUS_LIST.DRAFT; } @@ -199,9 +209,49 @@ onBeforeMount(async () => { isDevelopedInBC: response?.isDevelopedInBC, registeredName: response?.companyNameRegistered }, + housing: { + projectName: response?.projectName, + projectDescription: response?.projectDescription, + singleFamilySelected: !!response?.singleFamilyUnits, + multiFamilySelected: !!response?.multiFamilyUnits, + singleFamilyUnits: response?.singleFamilyUnits, + multiFamilyUnits: response?.multiFamilyUnits, + otherSelected: !!response?.otherUnits, + otherUnitsDescription: response?.otherUnitsDescription, + otherUnits: response?.otherUnits, + hasRentalUnits: response?.hasRentalUnits, + rentalUnits: response?.rentalUnits, + financiallySupportedBC: response?.financiallySupportedBC, + financiallySupportedIndigenous: response?.financiallySupportedIndigenous, + indigenousDescription: response?.indigenousDescription, + financiallySupportedNonProfit: response?.financiallySupportedNonProfit, + nonProfitDescription: response?.nonProfitDescription, + financiallySupportedHousingCoop: response?.financiallySupportedHousingCoop, + housingCoopDescription: response?.housingCoopDescription + }, location: { - province: 'BC' - } + naturalDisaster: response?.naturalDisaster, + projectLocation: response?.projectLocation, + streetAddress: response?.streetAddress, + locality: response?.locality, + province: response?.province, + latitude: response?.latitude, + longitude: response?.longitude, + ltsaPIDLookup: response?.locationPIDs, + geomarkUrl: response?.geomarkUrl, + projectLocationDescription: response?.projectLocationDescription + }, + appliedPermits: permits + .filter((x: Permit) => x.status === PERMIT_STATUS.APPLIED) + .map((x: Permit) => ({ + ...x, + statusLastVerified: x.statusLastVerified ? new Date(x.statusLastVerified) : undefined + })), + permits: { + hasAppliedProvincialPermits: response?.hasAppliedProvincialPermits, + checkProvincialPermits: response?.checkProvincialPermits + }, + investigatePermits: permits.filter((x: Permit) => x.needed === PERMIT_NEEDED.UNDER_INVESTIGATION) }; typeStore.setPermitTypes((await permitService.getPermitTypes()).data); @@ -439,7 +489,7 @@ onBeforeMount(async () => { @@ -1020,7 +1070,7 @@ onBeforeMount(async () => {