Skip to content

Commit 17a3711

Browse files
committed
Bug fixes
Contact info saving on intakes. Auto PID generation on intake. Correct assignee name in prop project view. Permit tracking create stamps. Project financially supported. Enquiry errors & reopen localization. Fill related enquiries field
1 parent efb4752 commit 17a3711

17 files changed

Lines changed: 115 additions & 78 deletions

File tree

app/src/controllers/housingProject.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
jsonToPrismaInputJson
99
} from '../db/utils/utils';
1010
import { createActivity, deleteActivity } from '../services/activity';
11-
import { upsertContacts } from '../services/contact';
1211
import { createDraft, deleteDraft, getDraft, getDrafts, updateDraft } from '../services/draft';
1312
import { email } from '../services/email';
1413
import {
@@ -157,11 +156,12 @@ const generateHousingProjectData = async (
157156
authStatus: PermitAuthorizationStatus.IN_REVIEW,
158157
submittedDate: x.submittedDate,
159158
adjudicationDate: null,
160-
permitTracking: x.permitTracking,
161-
createdAt: null,
162-
createdBy: null,
163-
updatedAt: null,
164-
updatedBy: null
159+
permitTracking: x.permitTracking?.map((pt) => ({
160+
...pt,
161+
...generateCreateStamps(currentContext)
162+
})),
163+
...generateCreateStamps(currentContext),
164+
...generateUpdateStamps(currentContext)
165165
}));
166166
}
167167

@@ -177,10 +177,8 @@ const generateHousingProjectData = async (
177177
authStatus: PermitAuthorizationStatus.NONE,
178178
submittedDate: null,
179179
adjudicationDate: null,
180-
createdAt: null,
181-
createdBy: null,
182-
updatedAt: null,
183-
updatedBy: null
180+
...generateCreateStamps(currentContext),
181+
...generateUpdateStamps(currentContext)
184182
}));
185183
}
186184

@@ -204,7 +202,6 @@ const generateHousingProjectData = async (
204202
updatedBy: null,
205203
aaiUpdated: false,
206204
assignedUserId: null,
207-
locationPids: null,
208205
queuePriority: null,
209206
relatedPermits: null,
210207
astNotes: null,
@@ -213,7 +210,12 @@ const generateHousingProjectData = async (
213210
atsClientId: null,
214211
ltsaCompleted: false,
215212
bcOnlineCompleted: false,
216-
financiallySupported: false,
213+
financiallySupported: [
214+
data.housing?.financiallySupportedBc,
215+
data.housing?.financiallySupportedIndigenous,
216+
data.housing?.financiallySupportedNonProfit,
217+
data.housing?.financiallySupportedHousingCoop
218+
].includes(BasicResponse.YES),
217219
waitingOn: null,
218220
checkProvincialPermits: null,
219221
atsEnquiryId: null
@@ -392,9 +394,6 @@ export const submitHousingProjectDraftController = async (
392394
req.currentContext
393395
);
394396

395-
// Create contacts
396-
if (req.body.contacts) await upsertContacts(tx, req.body.contacts);
397-
398397
// Create new housing project
399398
const data = await createHousingProject(tx, {
400399
...housingProject,

app/src/docs/v1.api-spec.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3816,10 +3816,6 @@ components:
38163816
description: Date it was submitted
38173817
format: date-time
38183818
example: '2024-04-03T00:57:09.070Z'
3819-
relatedEnquiries:
3820-
type: string
3821-
description: Related enquiries
3822-
example: Some enquiry
38233819
companyNameRegistered:
38243820
type: string
38253821
description: Name of the company connected to the project

app/src/services/map.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ function openMapsAxios(options: AxiosRequestConfig = {}): AxiosInstance {
1818
}
1919

2020
// eslint-disable-next-line @typescript-eslint/no-explicit-any
21-
function getPolygonArray(geoJSON: any) {
21+
function getPolygonArray(geoJson: any) {
2222
// eslint-disable-next-line @typescript-eslint/no-explicit-any
23-
const polygonArray = geoJSON?.geometry?.coordinates[0]?.map((c: any) => {
23+
const polygonArray = geoJson?.geometry?.coordinates[0]?.map((c: any) => {
2424
return { lat: c[1], lng: c[0] };
2525
});
2626
return polygonArray;
@@ -32,13 +32,13 @@ function getPolygonArray(geoJSON: any) {
3232
* Services Provided by OCIO - Digital Platforms & Data - Data Systems & Services
3333
* ref: https://docs.geoserver.org/main/en/user/services/wfs/reference.html#getfeature
3434
* ref: https://catalogue.data.gov.bc.ca/dataset/parcelmap-bc-parcel-fabric
35-
* @param geoJSON Geo JSON object to search within
35+
* @param geoJson Geo JSON object to search within
3636
* @returns parcel data in JSON
3737
*/
3838

3939
// eslint-disable-next-line @typescript-eslint/no-explicit-any
40-
export const getPIDs = async (geoJSON: any): Promise<string> => {
41-
const polygon = getPolygonArray(geoJSON);
40+
export const getPIDs = async (geoJson: any): Promise<string> => {
41+
const polygon = getPolygonArray(geoJson);
4242

4343
// close polygon by re-adding first point to end of array
4444
// define the source and destination layer types

app/tests/unit/controllers/housingProject.spec.ts

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ describe('createHousingProjectController', () => {
269269
};
270270

271271
createActivitySpy.mockResolvedValue(TEST_HOUSING_ACTIVITY);
272-
createHousingProjectSpy.mockResolvedValue(TEST_HOUSING_PROJECT_1);
272+
createHousingProjectSpy.mockResolvedValue(TEST_HOUSING_PROJECT_CREATE);
273273
upsertPermitSpy.mockResolvedValueOnce(TEST_PERMIT_1);
274274
upsertPermitSpy.mockResolvedValueOnce(TEST_PERMIT_2);
275275
upsertPermitSpy.mockResolvedValueOnce(TEST_PERMIT_3);
@@ -284,9 +284,27 @@ describe('createHousingProjectController', () => {
284284
expect(createHousingProjectSpy).toHaveBeenCalledTimes(1);
285285

286286
expect(upsertPermitSpy).toHaveBeenCalledTimes(3);
287-
expect(upsertPermitSpy).toHaveBeenNthCalledWith(1, prismaTxMock, TEST_PERMIT_1);
288-
expect(upsertPermitSpy).toHaveBeenNthCalledWith(2, prismaTxMock, TEST_PERMIT_2);
289-
expect(upsertPermitSpy).toHaveBeenNthCalledWith(3, prismaTxMock, TEST_PERMIT_3);
287+
expect(upsertPermitSpy).toHaveBeenNthCalledWith(1, prismaTxMock, {
288+
...TEST_PERMIT_1,
289+
createdAt: expect.any(Date),
290+
createdBy: TEST_CURRENT_CONTEXT.userId,
291+
updatedAt: expect.any(Date),
292+
updatedBy: TEST_CURRENT_CONTEXT.userId
293+
});
294+
expect(upsertPermitSpy).toHaveBeenNthCalledWith(2, prismaTxMock, {
295+
...TEST_PERMIT_2,
296+
createdAt: expect.any(Date),
297+
createdBy: TEST_CURRENT_CONTEXT.userId,
298+
updatedAt: expect.any(Date),
299+
updatedBy: TEST_CURRENT_CONTEXT.userId
300+
});
301+
expect(upsertPermitSpy).toHaveBeenNthCalledWith(3, prismaTxMock, {
302+
...TEST_PERMIT_3,
303+
createdAt: expect.any(Date),
304+
createdBy: TEST_CURRENT_CONTEXT.userId,
305+
updatedAt: expect.any(Date),
306+
updatedBy: TEST_CURRENT_CONTEXT.userId
307+
});
290308
expect(upsertPermitTrackingSpy).toHaveBeenCalledTimes(0);
291309
});
292310
});
@@ -645,9 +663,27 @@ describe('submitHousingProjectDraftController', () => {
645663
expect(upsertContacts).toHaveBeenCalledTimes(0);
646664
expect(createHousingProjectSpy).toHaveBeenCalledTimes(1);
647665
expect(upsertPermitSpy).toHaveBeenCalledTimes(3);
648-
expect(upsertPermitSpy).toHaveBeenNthCalledWith(1, prismaTxMock, TEST_PERMIT_1);
649-
expect(upsertPermitSpy).toHaveBeenNthCalledWith(2, prismaTxMock, TEST_PERMIT_2);
650-
expect(upsertPermitSpy).toHaveBeenNthCalledWith(3, prismaTxMock, TEST_PERMIT_3);
666+
expect(upsertPermitSpy).toHaveBeenNthCalledWith(1, prismaTxMock, {
667+
...TEST_PERMIT_1,
668+
createdAt: expect.any(Date),
669+
createdBy: TEST_CURRENT_CONTEXT.userId,
670+
updatedAt: expect.any(Date),
671+
updatedBy: TEST_CURRENT_CONTEXT.userId
672+
});
673+
expect(upsertPermitSpy).toHaveBeenNthCalledWith(2, prismaTxMock, {
674+
...TEST_PERMIT_2,
675+
createdAt: expect.any(Date),
676+
createdBy: TEST_CURRENT_CONTEXT.userId,
677+
updatedAt: expect.any(Date),
678+
updatedBy: TEST_CURRENT_CONTEXT.userId
679+
});
680+
expect(upsertPermitSpy).toHaveBeenNthCalledWith(3, prismaTxMock, {
681+
...TEST_PERMIT_3,
682+
createdAt: expect.any(Date),
683+
createdBy: TEST_CURRENT_CONTEXT.userId,
684+
updatedAt: expect.any(Date),
685+
updatedBy: TEST_CURRENT_CONTEXT.userId
686+
});
651687
expect(upsertPermitTrackingSpy).toHaveBeenCalledTimes(0);
652688
});
653689
});

frontend/src/components/electrification/project/ProjectIntakeForm.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ import { AutoComplete, FormAutosave, FormNavigationGuard, InputText, RadioList,
1111
import { CollectionDisclaimer, ContactCardIntakeForm } from '@/components/form/common';
1212
import { createProjectIntakeSchema } from '@/components/electrification/project/ProjectIntakeSchema';
1313
import { Button, Card, Message, useConfirm, useToast } from '@/lib/primevue';
14-
import { activityContactService, documentService, electrificationProjectService, externalApiService } from '@/services';
14+
import {
15+
activityContactService,
16+
contactService,
17+
documentService,
18+
electrificationProjectService,
19+
externalApiService
20+
} from '@/services';
1521
import { useConfigStore, useCodeStore, useContactStore, useProjectStore } from '@/store';
1622
import { RouteName } from '@/utils/enums/application';
1723
import { confirmationTemplateElectrificationSubmission, confirmationTemplateEnquiry } from '@/utils/templates';
@@ -181,15 +187,16 @@ async function onSubmit(data: any) {
181187
182188
if (response.data.activityId && response.data.electrificationProjectId) {
183189
// Link activity contact
184-
await activityContactService.updateActivityContact(response.data.activityId, [contact]);
190+
const contactResponse = (await contactService.updateContact(contact)).data;
191+
await activityContactService.updateActivityContact(response.data.activityId, [contactResponse]);
185192
186193
assignedActivityId.value = response.data.activityId;
187194
188195
// Send confirmation email
189196
emailConfirmation(response.data.activityId, response.data.electrificationProjectId, true);
190197
191198
// Save contact data to store
192-
contactStore.setContact(contact);
199+
contactStore.setContact(contactResponse);
193200
194201
router.push({
195202
name: RouteName.EXT_ELECTRIFICATION_INTAKE_CONFIRMATION,

frontend/src/components/form/common/LocationCard.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const setLongitude = useSetFieldValue('location.longitude');
4141
const setStreetAddress = useSetFieldValue('location.streetAddress');
4242
const setLocality = useSetFieldValue('location.locality');
4343
const setProvince = useSetFieldValue('location.province');
44-
const setGeoJSON = useSetFieldValue('location.geoJSON');
44+
const setGeoJson = useSetFieldValue('location.geoJson');
4545
const validateLatitude = useValidateField('location.latitude');
4646
const validateLongitude = useValidateField('location.longitude');
4747
@@ -60,8 +60,8 @@ function clearAddress() {
6060
setProvince(null);
6161
}
6262
63-
function clearGeoJSON() {
64-
setGeoJSON(null);
63+
function clearGeoJson() {
64+
setGeoJson(null);
6565
}
6666
6767
const getAddressSearchLabel = (e: GeocoderEntry) => {
@@ -99,7 +99,7 @@ async function onAddressSelect(e: SelectChangeEvent) {
9999
setLatitude(geometry?.coordinates[1]);
100100
setLongitude(geometry?.coordinates[0]);
101101
setProvince(properties?.provinceCode);
102-
clearGeoJSON();
102+
clearGeoJson();
103103
}
104104
}
105105
@@ -111,20 +111,20 @@ async function onLatLongInput() {
111111
const location = values.value?.location;
112112
if (mapRef.value?.pinToMap && (location.latitude || location.longitude)) {
113113
mapRef.value.pinToMap(location.latitude, location.longitude);
114-
clearGeoJSON();
114+
clearGeoJson();
115115
}
116116
}
117117
}
118118
119119
function onPolygonUpdate(data: any) {
120120
clearAddress();
121-
setGeoJSON(data.geoJSON);
121+
setGeoJson(data.geoJson);
122122
}
123123
124124
function onPinUpdate(pinUpdateEvent: PinUpdateEvent) {
125125
const addressSplit = pinUpdateEvent.address.split(',');
126126
clearAddress();
127-
clearGeoJSON();
127+
clearGeoJson();
128128
setStreetAddress(addressSplit[0]);
129129
setLocality(addressSplit[1]);
130130
setProvince(addressSplit[2]);
@@ -293,11 +293,11 @@ defineExpose({ resizeMap, onLatLongInput });
293293
ref="mapRef"
294294
:pin-or-draw="true"
295295
:disabled="!editable"
296-
:geo-json-data="values.location.geoJSON"
296+
:geo-json-data="values.location.geoJson"
297297
:latitude="mapLatitude"
298298
:longitude="mapLongitude"
299299
@map:erased="
300-
clearGeoJSON();
300+
clearGeoJson();
301301
clearAddress();
302302
"
303303
@map:polygon-updated="onPolygonUpdate"

frontend/src/components/housing/maps/Map.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const emit = defineEmits(['map:polygonUpdated', 'map:pinUpdated', 'map:erased'])
3939
// Actions
4040
let marker: L.Marker;
4141
let map: L.Map;
42-
const geoJSON: Ref<GeoJSON | undefined> = ref(undefined);
42+
const geoJson: Ref<GeoJSON | undefined> = ref(undefined);
4343
const toast = useToast();
4444
const oldLayer = ref<L.Layer | undefined>(undefined);
4545
@@ -96,9 +96,9 @@ async function initMap() {
9696
9797
getNearestOccupant(longitude, latitude);
9898
} else {
99-
geoJSON.value = geo.toGeoJSON();
99+
geoJson.value = geo.toGeoJSON();
100100
101-
emit('map:polygonUpdated', { geoJSON: toRaw(geoJSON.value) });
101+
emit('map:polygonUpdated', { geoJson: toRaw(geoJson.value) });
102102
}
103103
// Zoom in
104104
zoomToGeometry(geo);

frontend/src/components/housing/submission/SubmissionForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ onBeforeMount(async () => {
447447
448448
const locationPidsAuto = (await mapService.getPIDs(housingProject.housingProjectId)).data;
449449
450-
if (housingProject.geoJSON) geoJson.value = housingProject.geoJSON;
450+
if (housingProject.geoJson) geoJson.value = housingProject.geoJson;
451451
452452
const firstContact = housingProject?.activity?.activityContact?.[0]?.contact;
453453

frontend/src/components/housing/submission/SubmissionIntakeForm.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
} from '@/lib/primevue';
4848
import {
4949
activityContactService,
50+
contactService,
5051
documentService,
5152
enquiryService,
5253
externalApiService,
@@ -315,7 +316,8 @@ async function onSubmit(data: any) {
315316
316317
// Show the trackingNumber of all appliedPermits to the proponent
317318
dataOmitted.appliedPermits?.forEach((x: Permit) => {
318-
if (x?.permitTracking?.[0]) x.permitTracking[0].shownToProponent = true;
319+
if (x.permitTracking) x.permitTracking = x.permitTracking.filter((pt) => pt.trackingId);
320+
if (x.permitTracking[0]) x.permitTracking[0].shownToProponent = true;
319321
});
320322
321323
// Remove empty investigate permit objects
@@ -329,15 +331,16 @@ async function onSubmit(data: any) {
329331
330332
if (response.data.activityId && response.data.housingProjectId) {
331333
// Link activity contact
332-
await activityContactService.updateActivityContact(response.data.activityId, [contact]);
334+
const contactResponse = (await contactService.updateContact(contact)).data;
335+
await activityContactService.updateActivityContact(response.data.activityId, [contactResponse]);
333336
334337
assignedActivityId.value = response.data.activityId;
335338
336339
// Send confirmation email
337340
emailConfirmation(response.data.activityId, response.data.housingProjectId, true);
338341
339342
// Save contact data to store
340-
contactStore.setContact(contact);
343+
contactStore.setContact(contactResponse);
341344
342345
router.push({
343346
name: RouteName.EXT_HOUSING_INTAKE_CONFIRMATION,
@@ -460,7 +463,7 @@ onBeforeMount(async () => {
460463
ltsaPidLookup: response?.locationPids,
461464
geomarkUrl: response?.geomarkUrl,
462465
projectLocationDescription: response?.projectLocationDescription,
463-
geoJSON: response?.geoJSON
466+
geoJson: response?.geoJson
464467
},
465468
appliedPermits: permits
466469
.filter((x: Permit) => x.status === PermitStatus.APPLIED)

frontend/src/components/housing/submission/SubmissionIntakeSchema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export function createProjectIntakeSchema(orgBookOptions: Array<string>) {
149149
}),
150150
ltsaPidLookup: string().max(255).nullable().label('Parcel ID'),
151151
geomarkUrl: string().max(255).label('Geomark web service url'),
152-
getJSON: mixed().nullable().label('geoJSON')
152+
geoJson: mixed().nullable().label('geoJson')
153153
}),
154154
[IntakeFormCategory.PERMITS]: object({
155155
hasAppliedProvincialPermits: string().oneOf(YES_NO_UNSURE_LIST).required().label('Applied permits')

0 commit comments

Comments
 (0)