Skip to content

Commit

Permalink
Created permit status tracker and details view
Browse files Browse the repository at this point in the history
  • Loading branch information
qhanson55 committed Dec 3, 2024
1 parent d7b36d0 commit 9f51063
Show file tree
Hide file tree
Showing 18 changed files with 733 additions and 267 deletions.
14 changes: 14 additions & 0 deletions app/src/controllers/permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 7 additions & 6 deletions app/src/controllers/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
DraftCode,
IntakeStatus,
NumResidentialUnits,
PermitAuthorizationStatus,
PermitNeeded,
PermitStatus,
ProjectLocation,
Expand Down Expand Up @@ -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
}));
Expand All @@ -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
}));
Expand Down
4 changes: 3 additions & 1 deletion app/src/db/models/permit.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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)
};
},

Expand Down
29 changes: 29 additions & 0 deletions app/src/docs/v1.api-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions app/src/routes/v1/permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
7 changes: 4 additions & 3 deletions app/src/services/permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,20 @@ const service = {
* @function getPermit
* Get a permit
* @param {string} permitId Permit ID
* @returns {Promise<PermitType[]>} The result of running the findFirst operation
* @returns {Promise<Permit>} The result of running the findFirst operation
*/
getPermit: async (permitId: string) => {
const result = await prisma.permit.findFirst({
where: {
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;
},

/**
Expand Down
2 changes: 2 additions & 0 deletions app/src/types/Permit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { IStamps } from '../interfaces/IStamps';
import { PermitNote } from './PermitNote';
import { PermitType } from './PermitType';

export type Permit = {
permitId: string; // Primary Key
Expand All @@ -14,4 +15,5 @@ export type Permit = {
adjudicationDate: string | null;
statusLastVerified: string | null;
permitNote?: Array<PermitNote>;
permitType?: PermitType;
} & Partial<IStamps>;
6 changes: 6 additions & 0 deletions app/src/validators/permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)
};
5 changes: 4 additions & 1 deletion frontend/src/components/common/Breadcrumb.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ const { home, model } = defineProps<{
<template #item="{ item }">
<router-link
v-if="item.route"
:to="{ name: item.route }"
:to="{
name: item.route,
params: item.params
}"
>
<span
class="app-primary-color cursor-pointer hover-underline"
Expand Down
104 changes: 0 additions & 104 deletions frontend/src/components/housing/projects/ProjectStatus.vue

This file was deleted.

8 changes: 4 additions & 4 deletions frontend/src/components/permit/PermitCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const { getPermitTypes } = storeToRefs(useTypeStore());
const cardData = computed(() => permit);
const cardUpdatedBy: Ref<string> = ref('');
const permitModalVisible: Ref<boolean> = ref(false);
const NotesModalVisible: Ref<boolean> = ref(false);
const notesModalVisible: Ref<boolean> = ref(false);
const permitType: Ref<PermitType | undefined> = ref(
getPermitTypes.value.find((x) => x.permitTypeId === permit.permitTypeId)
);
Expand Down Expand Up @@ -65,7 +65,7 @@ function isCompleted(authStatus: string | undefined): boolean {
</script>

<template>
<Card :class="{ completed: isCompleted(cardData.authStatus), selected: NotesModalVisible }">
<Card :class="{ completed: isCompleted(cardData.authStatus), selected: notesModalVisible }">
<template #title>
<div class="flex align-items-center">
<div class="flex-grow-1">
Expand All @@ -84,7 +84,7 @@ function isCompleted(authStatus: string | undefined): boolean {
class="p-button-outlined"
aria-label="Add updates"
:disabled="!editable || !useAuthZStore().can(Initiative.HOUSING, Resource.PERMIT, Action.UPDATE)"
@click="NotesModalVisible = true"
@click="notesModalVisible = true"
>
<font-awesome-icon
class="pr-2"
Expand Down Expand Up @@ -184,7 +184,7 @@ function isCompleted(authStatus: string | undefined): boolean {
:permit="cardData"
/>
<NotesModal
v-model:visible="NotesModalVisible"
v-model:visible="notesModalVisible"
:permit="cardData"
/>
</template>
Expand Down
Loading

0 comments on commit 9f51063

Please sign in to comment.