-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: frontend modal and tab for notes page, submit functionality
- Loading branch information
Showing
19 changed files
with
469 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { default as chefsController } from './chefs'; | ||
export { default as documentController } from './document'; | ||
export { default as noteController } from './note'; | ||
export { default as permitController } from './permit'; | ||
export { default as userController } from './user'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { noteService } from '../services'; | ||
|
||
import type { NextFunction, Request, Response } from '../interfaces/IExpress'; | ||
|
||
const controller = { | ||
createNote: async (req: Request, res: Response, next: NextFunction) => { | ||
try { | ||
const response = await noteService.createNote(req.body, req.currentUser); | ||
res.status(200).send(response); | ||
} catch (e: unknown) { | ||
next(e); | ||
} | ||
}, | ||
|
||
async listNotes(req: Request<{ submissionId: string }>, res: Response, next: NextFunction) { | ||
try { | ||
const response = await noteService.listNotes(req.params.submissionId); | ||
res.status(200).send(response); | ||
} catch (e: unknown) { | ||
next(e); | ||
} | ||
} | ||
}; | ||
|
||
export default controller; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import express from 'express'; | ||
import { noteController } from '../../controllers'; | ||
import { requireSomeAuth } from '../../middleware/requireSomeAuth'; | ||
|
||
import type { NextFunction, Request, Response } from '../../interfaces/IExpress'; | ||
|
||
const router = express.Router(); | ||
router.use(requireSomeAuth); | ||
|
||
// note create endpoint | ||
router.put('/', (req: Request, res: Response, next: NextFunction): void => { | ||
noteController.createNote(req, res, next); | ||
}); | ||
|
||
// note list by submission endpoint | ||
router.get('/list/:submission_id', (req: Request, res: Response, next: NextFunction): void => { | ||
noteController.listNotes(req, res, next); | ||
}); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { default as chefsService } from './chefs'; | ||
export { default as documentService } from './document'; | ||
export { default as noteService } from './note'; | ||
export { default as permitService } from './permit'; | ||
export { default as userService } from './user'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import prisma from '../db/dataConnection'; | ||
import { note } from '../db/models'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
import { addDashesToUuid } from '../components/utils'; | ||
|
||
import type { Note } from '../types'; | ||
|
||
const service = { | ||
/** | ||
* @function createNote | ||
* Creates a Permit | ||
* @param note Note Object | ||
* @returns {Promise<object>} The result of running the findUnique operation | ||
*/ | ||
createNote: async (data: Note, currentUser: unknown) => { | ||
const newNote = { ...data, createdBy: addDashesToUuid(currentUser.tokenPayload.idir_user_guid), noteId: uuidv4() }; | ||
|
||
const create = await prisma.note.create({ | ||
include: { | ||
submission: { | ||
include: { user: true } | ||
} | ||
}, | ||
data: note.toPrismaModel(newNote) | ||
}); | ||
|
||
return note.fromPrismaModel(create); | ||
}, | ||
|
||
/** | ||
* @function deleteNote | ||
* Delete a note | ||
* @param noteId Note ID | ||
* @returns {Promise<object>} The result of running the delete operation | ||
*/ | ||
deleteNote: async (noteId: string) => { | ||
const response = await prisma.note.delete({ | ||
include: { | ||
submission: { | ||
include: { user: true } | ||
} | ||
}, | ||
where: { | ||
note_id: noteId | ||
} | ||
}); | ||
|
||
return note.fromPrismaModel(response); | ||
}, | ||
|
||
/** | ||
* @function listNotes | ||
* Retrieve a list of permits associated with a given submission | ||
* @param submissionId PCNS Submission ID | ||
* @returns {Promise<object>} Array of documents associated with the submission | ||
*/ | ||
listNotes: async (submissionId: string) => { | ||
const response = await prisma.note.findMany({ | ||
include: { | ||
submission: { | ||
include: { user: true } | ||
} | ||
}, | ||
where: { | ||
submission_id: submissionId | ||
} | ||
}); | ||
|
||
return response.map((x) => note.fromPrismaModel(x)); | ||
} | ||
}; | ||
|
||
export default service; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { IStamps } from '../interfaces/IStamps'; | ||
import type { ChefsSubmissionForm } from './ChefsSubmissionForm'; | ||
|
||
export type Note = { | ||
note_id: string; // Primary Key | ||
submission_id: string; | ||
category_type: string; | ||
noteId: string; // Primary Key | ||
submissionId: string; | ||
note: string; | ||
note_type: string; | ||
noteType: string; | ||
submission: ChefsSubmissionForm; | ||
title: string; | ||
} & Partial<IStamps>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<script setup lang="ts"> | ||
import { onMounted, ref } from 'vue'; | ||
import { Card } from '@/lib/primevue'; | ||
import { userService } from '@/services'; | ||
import { formatDate } from '@/utils/formatters'; | ||
import type { Ref } from 'vue'; | ||
import type { Note } from '@/types'; | ||
// Props | ||
type Props = { | ||
note: Note; | ||
submissionId: string; | ||
}; | ||
const props = withDefaults(defineProps<Props>(), {}); | ||
// State | ||
const cardData: Ref<Note> = ref(props.note); | ||
const userName: Ref<string> = ref(''); | ||
onMounted(async () => { | ||
if (props.note.createdBy) { | ||
const res = (await userService.searchUsers({ userId: [props.note.createdBy] })).data; | ||
userName.value = res.length ? res.pop().fullName : ''; | ||
} | ||
}); | ||
</script> | ||
|
||
<template> | ||
<Card> | ||
<template #header> | ||
<div class="flex flex-row px-3 pt-3"> | ||
<div class="flex-grow-1"> | ||
<h3>{{ cardData.title }}</h3> | ||
</div> | ||
</div> | ||
</template> | ||
<template #content> | ||
<div class="grid nested-grid"> | ||
<!-- Left column --> | ||
<div class="col-12 md:col-6 lg:col-4"> | ||
<div class="grid"> | ||
<p class="col-12"> | ||
<span class="key font-bold">Date:</span> | ||
{{ cardData.createdAt ? formatDate(cardData.createdAt ?? '') : undefined }} | ||
</p> | ||
</div> | ||
</div> | ||
<!-- Middle column --> | ||
<div class="col-12 md:col-6 lg:col-4"> | ||
<div class="grid"> | ||
<p class="col-12"> | ||
<span class="key font-bold">Author:</span> | ||
{{ userName }} | ||
</p> | ||
</div> | ||
</div> | ||
<!-- Right column --> | ||
<div class="col-12 md:col-6 lg:col-4"> | ||
<div class="grid"> | ||
<p class="col-12"> | ||
<span class="key font-bold">Category:</span> | ||
{{ cardData.noteType }} | ||
</p> | ||
</div> | ||
</div> | ||
<div class="col-12"> | ||
<p class="col-12"> | ||
{{ cardData.note }} | ||
</p> | ||
</div> | ||
</div> | ||
</template> | ||
</Card> | ||
</template> | ||
|
||
<style lang="scss"> | ||
h2 { | ||
margin: 0; | ||
} | ||
p { | ||
margin-top: 0; | ||
margin-bottom: 0; | ||
} | ||
.key { | ||
color: #38598a; | ||
} | ||
.p-card { | ||
border-style: solid; | ||
border-width: 1px; | ||
.p-card-body { | ||
padding-top: 0; | ||
padding-bottom: 0; | ||
.p-card-content { | ||
padding-bottom: 0; | ||
} | ||
} | ||
} | ||
</style> |
Oops, something went wrong.