Skip to content

Commit

Permalink
Loading initial values for intake and enquiry
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle1morel committed Jun 4, 2024
1 parent 4389eeb commit cd2ae86
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 53 deletions.
4 changes: 2 additions & 2 deletions app/src/controllers/enquiry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions app/src/services/enquiry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Enquiry | null>} 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
}
});

Expand Down
10 changes: 8 additions & 2 deletions frontend/src/components/housing/intake/ShasEnquiryForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
}
};
});
Expand Down
92 changes: 71 additions & 21 deletions frontend/src/components/housing/intake/ShasIntakeForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -176,9 +184,11 @@ async function onSubmit(data: any) {
}
onBeforeMount(async () => {
let response;
if (props.submissionId) {
let response,
permits: Array<Permit> = [];
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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -439,7 +489,7 @@ onBeforeMount(async () => {
<InputText
class="col-6"
name="housing.projectName"
label="Type in project - well known title like Capital Park"
label="Project name - well known title like Capital Park"
:bold="false"
:disabled="!editable"
/>
Expand Down Expand Up @@ -1020,7 +1070,7 @@ onBeforeMount(async () => {
<template #content>
<TextArea
class="col-12"
name="housing.projectLocationDescription"
name="location.projectLocationDescription"
:disabled="!editable"
/>
</template>
Expand Down Expand Up @@ -1171,7 +1221,7 @@ onBeforeMount(async () => {
push({
permitTypeId: undefined,
trackingId: undefined,
status: undefined
statusLastVerified: undefined
})
"
>
Expand Down Expand Up @@ -1264,19 +1314,18 @@ onBeforeMount(async () => {
:index="idx"
class="w-full flex align-items-center"
>
<Dropdown
class="col-4"
:name="`investigatePermits[${idx}].permitTypeId`"
placeholder="Select Permit type"
`
:options="getPermitTypes"
:option-label="(e) => `${e.businessDomain}: ${e.name}`"
option-value="permitTypeId"
:loading="getPermitTypes === undefined"
/>
<div class="col-1">
<div class="flex justify-content-left">
<div class="flex align-items-center mb-3">
<div class="col-4">
<div class="flex justify-content-center">
<Dropdown
class="w-full"
:name="`investigatePermits[${idx}].permitTypeId`"
placeholder="Select Permit type"
:options="getPermitTypes"
:option-label="(e) => `${e.businessDomain}: ${e.name}`"
option-value="permitTypeId"
:loading="getPermitTypes === undefined"
/>
<div class="flex align-items-center ml-2 mb-4">
<Button
class="p-button-lg p-button-text p-button-danger p-0"
aria-label="Delete"
Expand All @@ -1287,6 +1336,7 @@ onBeforeMount(async () => {
</div>
</div>
</div>

<div class="col" />
</div>
<div class="col-12">
Expand Down
27 changes: 14 additions & 13 deletions frontend/src/components/layout/DevelopmentRoleOverride.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ const router = useRouter();
// State
const role: Ref<string | undefined> = ref(permissionService.getRoleOverride());
// Actions
function clearRole() {
permissionService.setRoleOverride(undefined);
role.value = undefined;
router.push({ name: RouteNames.HOME });
}
function setRole(e: any) {
permissionService.setRoleOverride(e.value);
router.push({ name: RouteNames.HOME });
}
</script>

<template>
Expand All @@ -27,24 +39,13 @@ const role: Ref<string | undefined> = ref(permissionService.getRoleOverride());
v-model="role"
class="w-full"
:options="AccessRoles"
@change="
(e) => {
permissionService.setRoleOverride(e.value);
router.push({ name: RouteNames.HOME });
}
"
@change="(e) => setRole(e)"
/>
</div>
<div>
<Button
secondary
@click="
(e) => {
permissionService.setRoleOverride(undefined);
role = undefined;
router.push({ name: RouteNames.HOME });
}
"
@click="clearRole"
>
End
</Button>
Expand Down
25 changes: 15 additions & 10 deletions frontend/src/components/layout/LoginButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,23 @@ import { Button } from '@/lib/primevue';
import { useAuthStore } from '@/store/authStore';
import { RouteNames } from '@/utils/constants';
const router = useRouter();
// Store
const authStore = useAuthStore();
const { getIsAuthenticated } = storeToRefs(authStore);
// Actions
const router = useRouter();
function isLoginEnabled() {
return (
!getIsAuthenticated &&
router.currentRoute.value.name &&
![RouteNames.HOME, RouteNames.OIDC_LOGIN, RouteNames.OIDC_CALLBACK, RouteNames.OIDC_LOGOUT].includes(
router.currentRoute.value.name as any
)
);
}
function login() {
router.push({ name: RouteNames.OIDC_LOGIN });
}
Expand All @@ -22,14 +34,7 @@ function logout() {

<template>
<Button
v-if="
!getIsAuthenticated &&
router.currentRoute.value.name &&
router.currentRoute.value.name !== RouteNames.HOME &&
![RouteNames.OIDC_LOGIN, RouteNames.OIDC_CALLBACK, RouteNames.OIDC_LOGOUT].includes(
router.currentRoute.value.name as any
)
"
v-if="isLoginEnabled()"
severity="secondary"
outlined
@click="login()"
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types/Permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export type Permit = {
status?: string;
submittedDate?: string;
adjudicationDate?: string;
statusLastVerified?: string;
} & Partial<IStamps>;
4 changes: 2 additions & 2 deletions frontend/src/views/housing/HousingView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const items = ref([
<img
class="mr-3"
src="@/assets/images/house.png"
width="147"
height="141"
width="67"
height="64"
alt="Housing image"
/>
<h1 class="app-primary-color">Housing</h1>
Expand Down

0 comments on commit cd2ae86

Please sign in to comment.