Skip to content

Commit c45a859

Browse files
authored
Merge pull request #3480 from Northeastern-Electric-Racing/final-misc-changes
Final misc changes
2 parents 546213b + 4c92b16 commit c45a859

27 files changed

Lines changed: 926 additions & 698 deletions

File tree

src/backend/src/controllers/part-review.controllers.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default class PartReviewController {
99
const { wbsNum, indexNum } = req.params;
1010

1111
const wbsNumber: WbsNumber = validateWBS(wbsNum);
12-
const part = await PartReviewService.getPart(req.organization, wbsNumber, indexNum);
12+
const part = await PartReviewService.getPart(req.organization, req.currentUser, wbsNumber, indexNum);
1313
res.status(200).json(part);
1414
} catch (error: unknown) {
1515
next(error);
@@ -148,6 +148,16 @@ export default class PartReviewController {
148148
}
149149
}
150150

151+
static async deleteReview(req: Request, res: Response, next: NextFunction) {
152+
try {
153+
const { reviewId } = req.params;
154+
await PartReviewService.deleteReview(reviewId, req.currentUser, req.organization.organizationId);
155+
res.status(200).json({ message: 'Successfully deleted review' });
156+
} catch (error: unknown) {
157+
next(error);
158+
}
159+
}
160+
151161
static async createSubmission(req: Request, res: Response, next: NextFunction) {
152162
try {
153163
const { partId, name, fileIds, notes } = req.body;
@@ -362,6 +372,26 @@ export default class PartReviewController {
362372
}
363373
}
364374

375+
static async notifyReviewer(req: Request, res: Response, next: NextFunction) {
376+
try {
377+
const { reviewerId, partId } = req.body;
378+
await PartReviewService.notifyReviewer(reviewerId, partId, req.organization.organizationId);
379+
res.status(200).json({ message: 'Successfully notified reviewer' });
380+
} catch (error) {
381+
next(error);
382+
}
383+
}
384+
385+
static async notifyAssignee(req: Request, res: Response, next: NextFunction) {
386+
try {
387+
const { assigneeId, partId } = req.body;
388+
await PartReviewService.notifyAssignee(assigneeId, partId, req.organization.organizationId);
389+
res.status(200).json({ message: 'Successfully notified assignee' });
390+
} catch (error) {
391+
next(error);
392+
}
393+
}
394+
365395
static async createPartReviewPopup(req: Request, res: Response, next: NextFunction) {
366396
try {
367397
const user = req.currentUser;

src/backend/src/prisma/seed-data/parts.seed.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const basicPart = (projectId: string, userCreatedId: string, assigneeIds: string
1111
index: 1,
1212
commonName: 'Basic Part',
1313
description: 'Basic part with all fields populated',
14-
previewImageId: 'https://NER.com/basicpart.jpg',
1514
status: 'IN_PROGRESS',
1615
createdAt: new Date('2025-01-01T10:00:00Z'),
1716
project: {
@@ -32,7 +31,6 @@ const partWithoutDescription = (projectId: string, userCreatedId: string, assign
3231
data: {
3332
index: 2,
3433
commonName: 'Part without description',
35-
previewImageId: 'https://NER.com/partwithoutdes.jpg',
3634
status: 'IN_PROGRESS',
3735
createdAt: new Date('2025-01-01T10:00:00Z'),
3836
project: {
@@ -74,7 +72,6 @@ const partWithEmptyHistory = (projectId: string, userCreatedId: string, assignee
7472
index: 4,
7573
commonName: 'Part with empty history',
7674
description: 'Basic part but with empty history',
77-
previewImageId: 'https://NER.com/partemptyhistory.jpg',
7875
status: 'IN_PROGRESS',
7976
createdAt: new Date('2025-01-01T10:00:00Z'),
8077
project: {
@@ -95,7 +92,6 @@ const partWithLongName = (projectId: string, userCreatedId: string, assigneeIds:
9592
index: 5,
9693
commonName: 'ThisPartHasANameThatIsWayTooLongAndMightCauseProblemsWithVisibilityOnTheWebsiteMaybeIDK',
9794
description: 'part with super long name',
98-
previewImageId: 'https://NER.com/partwithlongname.jpg',
9995
status: 'IN_PROGRESS',
10096
createdAt: new Date('2025-01-01T10:00:00Z'),
10197
project: {
@@ -116,7 +112,6 @@ const partIndexNegative = (projectId: string, userCreatedId: string, assigneeIds
116112
index: -1,
117113
commonName: 'Part with negative index',
118114
description: 'This parts index is negative',
119-
previewImageId: 'https://NER.com/negativeindexpart.jpg',
120115
status: 'IN_PROGRESS',
121116
createdAt: new Date('2025-01-01T10:00:00Z'),
122117
project: {
@@ -137,7 +132,6 @@ const partIndexZero = (projectId: string, userCreatedId: string, assigneeIds: st
137132
index: 0,
138133
commonName: 'Part with index 0',
139134
description: 'This parts index is 0',
140-
previewImageId: 'https://NER.com/zeroindexpart.jpg',
141135
status: 'IN_PROGRESS',
142136
createdAt: new Date('2025-01-01T10:00:00Z'),
143137
project: {
@@ -158,7 +152,6 @@ const partIndexLarge = (projectId: string, userCreatedId: string, assigneeIds: s
158152
index: 99999999,
159153
commonName: 'Part with very large index',
160154
description: 'This part index is very large',
161-
previewImageId: 'https://NER.com/largeindexpart.jpg',
162155
status: 'IN_PROGRESS',
163156
createdAt: new Date('2025-01-01T10:00:00Z'),
164157
project: {
@@ -179,7 +172,6 @@ const partReadyForReview = (projectId: string, userCreatedId: string, assigneeId
179172
index: 9,
180173
commonName: 'Part with READY_FOR_REVIEW status',
181174
description: 'This part is ready for review',
182-
previewImageId: 'https://NER.com/testimage.jpg',
183175
status: 'READY_FOR_REVIEW',
184176
createdAt: new Date('2025-01-01T10:00:00Z'),
185177
project: {
@@ -200,7 +192,6 @@ const partInReview = (projectId: string, userCreatedId: string, assigneeIds: str
200192
index: 10,
201193
commonName: 'Part with IN_REVIEW status',
202194
description: 'This part is in review',
203-
previewImageId: 'https://NER.com/testimage.jpg',
204195
status: 'IN_REVIEW',
205196
createdAt: new Date('2025-01-01T10:00:00Z'),
206197
project: {
@@ -221,7 +212,6 @@ const partReviewed = (projectId: string, userCreatedId: string, assigneeIds: str
221212
index: 11,
222213
commonName: 'Part with REVIEWED status',
223214
description: 'This part is reviewed.',
224-
previewImageId: 'https://NER.com/testimage.jpg',
225215
status: 'REVIEWED',
226216
createdAt: new Date('2025-01-01T10:00:00Z'),
227217
project: {
@@ -242,7 +232,6 @@ const partApproved = (projectId: string, userCreatedId: string, assigneeIds: str
242232
index: 12,
243233
commonName: 'Part with APPROVED status',
244234
description: 'This part is approved.',
245-
previewImageId: 'https://NER.com/testimage.jpg',
246235
status: 'APPROVED',
247236
createdAt: new Date('2025-01-01T10:00:00Z'),
248237
project: {
@@ -263,7 +252,6 @@ const partCurrentDate = (projectId: string, userCreatedId: string, assigneeIds:
263252
index: 13,
264253
commonName: 'Part with current date',
265254
description: 'This part has the current date.',
266-
previewImageId: 'https://NER.com/testimage.jpg',
267255
status: 'APPROVED',
268256
createdAt: new Date(),
269257
project: {
@@ -284,7 +272,6 @@ const partPastDate = (projectId: string, userCreatedId: string, assigneeIds: str
284272
index: 14,
285273
commonName: 'Part with past date',
286274
description: 'This part is old.',
287-
previewImageId: 'https://NER.com/testimage.jpg',
288275
status: 'APPROVED',
289276
createdAt: new Date('2000-01-01T00:00:00Z'),
290277
project: {
@@ -305,7 +292,6 @@ const partUnixEpochDate = (projectId: string, userCreatedId: string, assigneeIds
305292
index: 15,
306293
commonName: 'Part with date of Unix Epoch',
307294
description: 'This part is was made at the unix epoch.',
308-
previewImageId: 'https://NER.com/testimage.jpg',
309295
status: 'APPROVED',
310296
createdAt: new Date('1970-01-01T00:00:00Z'),
311297
project: {
@@ -326,7 +312,6 @@ const partFutureDate = (projectId: string, userCreatedId: string, assigneeIds: s
326312
index: 16,
327313
commonName: 'Part with date of future',
328314
description: 'This part is was made in the future.',
329-
previewImageId: 'https://NER.com/testimage.jpg',
330315
status: 'APPROVED',
331316
createdAt: new Date('2100-12-31T23:59:59Z'),
332317
project: {
@@ -347,7 +332,6 @@ const partLeapYearDate = (projectId: string, userCreatedId: string, assigneeIds:
347332
index: 17,
348333
commonName: 'Part with date with a leap year',
349334
description: 'This part is was during a leap year.',
350-
previewImageId: 'https://NER.com/testimage.jpg',
351335
status: 'APPROVED',
352336
createdAt: new Date('2024-02-29T12:00:00Z'),
353337
project: {

src/backend/src/routes/parts.routes.ts

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ partsRouter.post(
5151
PartReviewController.updateReview
5252
);
5353

54+
partsRouter.post('/review/:reviewId/delete', PartReviewController.deleteReview);
55+
5456
partsRouter.post(
5557
'/submission/create',
5658
nonEmptyString(body('partId')),
@@ -164,50 +166,28 @@ partsRouter.post('/popup/:popupId/delete', PartReviewController.deletePartReview
164166
partsRouter.post('/reviewRequest/:reviewRequestId/delete', PartReviewController.deletePartReviewRequest);
165167

166168
partsRouter.post(
167-
'/:partId/reviewRequest/create',
169+
'/notifyReviewer',
168170
nonEmptyString(body('reviewerId')),
171+
nonEmptyString(body('partId')),
169172
validateInputs,
170-
PartReviewController.createPartReviewRequest
173+
PartReviewController.notifyReviewer
171174
);
172-
partsRouter.post('/reviewRequest/:reviewRequestId/delete', PartReviewController.deletePartReviewRequest);
173-
174-
partsRouter.post('/:partId/upload-preview', upload.single('image'), PartReviewController.uploadPreview);
175175

176176
partsRouter.post(
177-
'/:partId/update',
178-
intMinZero(body('index')),
179-
nonEmptyString(body('commonName')),
180-
body('description').optional().isString(),
181-
body('reviewStatus').custom((value) => Object.values(Review_Status).includes(value)),
182-
body('tagIds').isArray(),
183-
body('assigneeIds').isArray(),
184-
body('reviewerIds').isArray(),
177+
'/notifyAssignee',
178+
nonEmptyString(body('assigneeId')),
179+
nonEmptyString(body('partId')),
185180
validateInputs,
186-
PartReviewController.updatePart
181+
PartReviewController.notifyAssignee
187182
);
188183

189-
partsRouter.post('/:partId/delete', PartReviewController.deletePart);
190-
191-
partsRouter.get('/:wbsNum', PartReviewController.getAllPartsForProject);
192-
193-
partsRouter.post('/:partId/upload-preview', upload.single('image'), PartReviewController.uploadPreview);
194-
195184
partsRouter.post(
196-
'/:partId/update',
197-
intMinZero(body('index')),
198-
nonEmptyString(body('commonName')),
199-
body('description').optional().isString(),
200-
body('reviewStatus').custom((value) => Object.values(Review_Status).includes(value)),
201-
body('tagIds').isArray(),
202-
body('assigneeIds').isArray(),
185+
'/:partId/reviewRequest/create',
186+
nonEmptyString(body('reviewerId')),
203187
validateInputs,
204-
PartReviewController.updatePart
188+
PartReviewController.createPartReviewRequest
205189
);
206190

207-
partsRouter.post('/:partId/delete', PartReviewController.deletePart);
208-
209-
partsRouter.get('/:wbsNum', PartReviewController.getAllPartsForProject);
210-
211191
partsRouter.post('/:partId/upload-preview', upload.single('image'), PartReviewController.uploadPreview);
212192

213193
partsRouter.post(

0 commit comments

Comments
 (0)