From 9f51063995d6a07793aa11b1c05eedcf20eb586d Mon Sep 17 00:00:00 2001 From: qhanson55 Date: Mon, 2 Dec 2024 18:09:57 -0800 Subject: [PATCH] Created permit status tracker and details view --- app/src/controllers/permit.ts | 14 + app/src/controllers/submission.ts | 13 +- app/src/db/models/permit.ts | 4 +- app/src/docs/v1.api-spec.yaml | 29 + app/src/routes/v1/permit.ts | 11 + app/src/services/permit.ts | 7 +- app/src/types/Permit.ts | 2 + app/src/validators/permit.ts | 6 + frontend/src/components/common/Breadcrumb.vue | 5 +- .../housing/projects/ProjectStatus.vue | 104 ---- frontend/src/components/permit/PermitCard.vue | 8 +- .../PermitEnquiryModal.vue} | 119 ++-- .../src/components/permit/PermitModal.vue | 16 +- frontend/src/router/index.ts | 10 + frontend/src/services/permitService.ts | 8 + frontend/src/utils/enums/application.ts | 1 + .../src/views/housing/project/ProjectView.vue | 124 ++--- .../src/views/permit/PermitStatusView.vue | 519 ++++++++++++++++++ 18 files changed, 733 insertions(+), 267 deletions(-) delete mode 100644 frontend/src/components/housing/projects/ProjectStatus.vue rename frontend/src/components/{housing/projects/ProjectPermitModal.vue => permit/PermitEnquiryModal.vue} (55%) create mode 100644 frontend/src/views/permit/PermitStatusView.vue diff --git a/app/src/controllers/permit.ts b/app/src/controllers/permit.ts index ca173d37..26e2b489 100644 --- a/app/src/controllers/permit.ts +++ b/app/src/controllers/permit.ts @@ -33,6 +33,20 @@ const controller = { } }, + getPermit: async (req: Request<{ permitId: string }>, res: Response, next: NextFunction) => { + try { + const response = await permitService.getPermit(req.params.permitId); + + if (!response) { + return res.status(404).json({ message: 'Permit not found' }); + } + + res.status(200).json(response); + } catch (e: unknown) { + next(e); + } + }, + getPermitTypes: async (req: Request, res: Response, next: NextFunction) => { try { const response = await permitService.getPermitTypes(); diff --git a/app/src/controllers/submission.ts b/app/src/controllers/submission.ts index 73c09e3c..01178597 100644 --- a/app/src/controllers/submission.ts +++ b/app/src/controllers/submission.ts @@ -17,6 +17,7 @@ import { DraftCode, IntakeStatus, NumResidentialUnits, + PermitAuthorizationStatus, PermitNeeded, PermitStatus, ProjectLocation, @@ -295,11 +296,11 @@ const controller = { permitTypeId: x.permitTypeId, activityId: activityId as string, trackingId: x.trackingId, - status: PermitStatus.APPLIED, - needed: null, + status: x.status ?? PermitStatus.APPLIED, + needed: x.needed ?? PermitNeeded.YES, statusLastVerified: x.statusLastVerified, issuedPermitId: null, - authStatus: null, + authStatus: x.authStatus ?? PermitAuthorizationStatus.IN_REVIEW, submittedDate: null, adjudicationDate: null })); @@ -311,11 +312,11 @@ const controller = { permitTypeId: x.permitTypeId as number, activityId: activityId as string, trackingId: null, - status: null, - needed: PermitNeeded.UNDER_INVESTIGATION, + status: x.status ?? PermitStatus.NEW, + needed: x.needed ?? PermitNeeded.UNDER_INVESTIGATION, statusLastVerified: x.statusLastVerified, issuedPermitId: null, - authStatus: null, + authStatus: x.authStatus ?? PermitAuthorizationStatus.NONE, submittedDate: null, adjudicationDate: null })); diff --git a/app/src/db/models/permit.ts b/app/src/db/models/permit.ts index b570844b..f015ed14 100644 --- a/app/src/db/models/permit.ts +++ b/app/src/db/models/permit.ts @@ -1,6 +1,7 @@ import { Prisma } from '@prisma/client'; import permit_note from './permit_note'; +import permit_type from './permit_type'; import type { Stamps } from '../stamps'; import type { Permit } from '../../types'; @@ -47,7 +48,8 @@ export default { adjudicationDate: input.adjudication_date?.toISOString() ?? null, statusLastVerified: input.status_last_verified?.toISOString() ?? null, updatedAt: input.updated_at?.toISOString() ?? null, - updatedBy: input.updated_by + updatedBy: input.updated_by, + permitType: permit_type.fromPrismaModel(input.permit_type) }; }, diff --git a/app/src/docs/v1.api-spec.yaml b/app/src/docs/v1.api-spec.yaml index 3df6f921..f9652225 100644 --- a/app/src/docs/v1.api-spec.yaml +++ b/app/src/docs/v1.api-spec.yaml @@ -491,6 +491,35 @@ paths: default: $ref: '#/components/responses/Error' /permit/{permitId}: + get: + summary: Get a permit + operationId: getPermit + tags: + - Permit + parameters: + - in: path + name: permitId + required: true + schema: + type: string + description: The ID of the permit to update + responses: + '200': + description: Permit updated successfully + content: + application/json: + schema: + $ref: '#/components/schemas/DB-Permit' + "401": + $ref: "#/components/responses/Unauthorized" + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + "422": + $ref: "#/components/responses/UnprocessableEntity" + default: + $ref: '#/components/responses/Error' put: summary: Update a permit operationId: updatePermit diff --git a/app/src/routes/v1/permit.ts b/app/src/routes/v1/permit.ts index a265c42e..a6d2e8ba 100644 --- a/app/src/routes/v1/permit.ts +++ b/app/src/routes/v1/permit.ts @@ -67,4 +67,15 @@ router.get( } ); +// Permit get endpoint +router.get( + '/:permitId', + hasAuthorization(Resource.PERMIT, Action.READ), + hasAccess('permitId'), + permitValidator.getPermit, + (req: Request<{ permitId: string }>, res: Response, next: NextFunction): void => { + permitController.getPermit(req, res, next); + } +); + export default router; diff --git a/app/src/services/permit.ts b/app/src/services/permit.ts index 6c0d6612..bb33ba11 100644 --- a/app/src/services/permit.ts +++ b/app/src/services/permit.ts @@ -68,7 +68,7 @@ const service = { * @function getPermit * Get a permit * @param {string} permitId Permit ID - * @returns {Promise} The result of running the findFirst operation + * @returns {Promise} The result of running the findFirst operation */ getPermit: async (permitId: string) => { const result = await prisma.permit.findFirst({ @@ -76,11 +76,12 @@ const service = { permit_id: permitId }, include: { - permit_type: true + permit_type: true, + permit_note: { orderBy: { created_at: 'desc' } } } }); - return result ? permit.fromPrismaModel(result) : null; + return result ? permit.fromPrismaModelWithNotes(result) : null; }, /** diff --git a/app/src/types/Permit.ts b/app/src/types/Permit.ts index 667cd2ee..0867f0a1 100644 --- a/app/src/types/Permit.ts +++ b/app/src/types/Permit.ts @@ -1,5 +1,6 @@ import { IStamps } from '../interfaces/IStamps'; import { PermitNote } from './PermitNote'; +import { PermitType } from './PermitType'; export type Permit = { permitId: string; // Primary Key @@ -14,4 +15,5 @@ export type Permit = { adjudicationDate: string | null; statusLastVerified: string | null; permitNote?: Array; + permitType?: PermitType; } & Partial; diff --git a/app/src/validators/permit.ts b/app/src/validators/permit.ts index 861b0396..e87cb4d4 100644 --- a/app/src/validators/permit.ts +++ b/app/src/validators/permit.ts @@ -27,6 +27,11 @@ const schema = { permitId: uuidv4.required() }) }, + getPermit: { + params: Joi.object({ + permitId: uuidv4.required() + }) + }, listPermits: { query: Joi.object({ activityId: Joi.string().min(8).max(8).allow(null), @@ -47,6 +52,7 @@ const schema = { export default { createPermit: validate(schema.createPermit), deletePermit: validate(schema.deletePermit), + getPermit: validate(schema.getPermit), listPermits: validate(schema.listPermits), updatePermit: validate(schema.updatePermit) }; diff --git a/frontend/src/components/common/Breadcrumb.vue b/frontend/src/components/common/Breadcrumb.vue index 86f5db70..19daaad6 100644 --- a/frontend/src/components/common/Breadcrumb.vue +++ b/frontend/src/components/common/Breadcrumb.vue @@ -19,7 +19,10 @@ const { home, model } = defineProps<{