Skip to content

Commit ac487a0

Browse files
committed
Merge branch 'develop' into 1523-bom-delete-manufacturer-endpoint
2 parents 64b119a + da6d5b9 commit ac487a0

48 files changed

Lines changed: 1223 additions & 76 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/backend/src/controllers/projects.controllers.ts

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,14 @@ export default class ProjectsController {
167167
manufacturerName,
168168
manufacturerPartNumber,
169169
quantity,
170-
unitName,
171170
price,
172171
subtotal,
173172
linkUrl,
174173
notes,
175174
wbsNum,
176175
assemblyId,
177-
pdmFileName
176+
pdmFileName,
177+
unitName
178178
);
179179
return res.status(200).json(material);
180180
} catch (error: unknown) {
@@ -204,6 +204,16 @@ export default class ProjectsController {
204204
}
205205
}
206206

207+
static async getAllManufacturers(req: Request, res: Response, next: NextFunction) {
208+
try {
209+
const user = await getCurrentUser(res);
210+
const manufacturers: Manufacturer[] = await ProjectsService.getAllManufacturers(user);
211+
return res.status(200).json(manufacturers);
212+
} catch (error: unknown) {
213+
next(error);
214+
}
215+
}
216+
207217
static async createMaterialType(req: Request, res: Response, next: NextFunction) {
208218
try {
209219
const { name } = req.body;
@@ -214,4 +224,68 @@ export default class ProjectsController {
214224
next(error);
215225
}
216226
}
227+
228+
static async deleteAssemblyType(req: Request, res: Response, next: NextFunction) {
229+
try {
230+
const { assemblyId } = req.params;
231+
const user = await getCurrentUser(res);
232+
const deletedAssembly = await ProjectsService.deleteAssembly(assemblyId, user);
233+
res.status(200).json(deletedAssembly);
234+
} catch (error: unknown) {
235+
next(error);
236+
}
237+
}
238+
239+
static async deleteMaterialType(req: Request, res: Response, next: NextFunction) {
240+
try {
241+
const { materialTypeId } = req.params;
242+
const user = await getCurrentUser(res);
243+
const deletedMaterial = await ProjectsService.deleteMaterialType(materialTypeId, user);
244+
res.status(200).json(deletedMaterial);
245+
} catch (error: unknown) {
246+
next(error);
247+
}
248+
}
249+
250+
static async editMaterial(req: Request, res: Response, next: NextFunction) {
251+
try {
252+
const user = await getCurrentUser(res);
253+
const { materialId } = req.params;
254+
const {
255+
name,
256+
assemblyId,
257+
status,
258+
materialTypeName,
259+
manufacturerName,
260+
manufacturerPartNumber,
261+
pdmFileName,
262+
quantity,
263+
unitName,
264+
price,
265+
subtotal,
266+
linkUrl,
267+
notes
268+
} = req.body;
269+
const updatedMaterial = await ProjectsService.editMaterial(
270+
user,
271+
materialId,
272+
name,
273+
status,
274+
materialTypeName,
275+
manufacturerName,
276+
manufacturerPartNumber,
277+
quantity,
278+
price,
279+
subtotal,
280+
linkUrl,
281+
notes,
282+
unitName,
283+
assemblyId,
284+
pdmFileName
285+
);
286+
res.status(200).json(updatedMaterial);
287+
} catch (error: unknown) {
288+
next(error);
289+
}
290+
}
217291
}

src/backend/src/controllers/reimbursement-requests.controllers.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,17 @@ export default class ReimbursementRequestsController {
230230
}
231231
}
232232

233+
static async denyReimbursementRequest(req: Request, res: Response, next: NextFunction) {
234+
try {
235+
const { requestId } = req.params;
236+
const user = await getCurrentUser(res);
237+
const reimbursementStatus = await ReimbursementRequestService.denyReimbursementRequest(requestId, user);
238+
res.status(200).json(reimbursementStatus);
239+
} catch (error: unknown) {
240+
next(error);
241+
}
242+
}
243+
233244
static async markReimbursementRequestAsDelivered(req: Request, res: Response, next: NextFunction) {
234245
try {
235246
const { requestId } = req.params;

src/backend/src/controllers/work-packages.controllers.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ export default class WorkPackagesController {
2929
}
3030
}
3131

32+
static async getManyWorkPackages(req: Request, res: Response, next: NextFunction) {
33+
try {
34+
const { wbsNums } = req.body;
35+
const workPackages: WorkPackage[] = await WorkPackagesService.getManyWorkPackages(wbsNums);
36+
res.status(200).json(workPackages);
37+
} catch (error: unknown) {
38+
next(error);
39+
}
40+
}
41+
3242
// Create a work package with the given details
3343
static async createWorkPackage(req: Request, res: Response, next: NextFunction) {
3444
try {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* This file is part of NER's FinishLine and licensed under GNU AGPLv3.
3+
* See the LICENSE file in the repository root folder for details.
4+
*/
5+
6+
import { Prisma } from '@prisma/client';
7+
8+
const manufacturerQueryArgs = Prisma.validator<Prisma.ManufacturerArgs>()({
9+
include: {
10+
materials: true
11+
}
12+
});
13+
14+
export default manufacturerQueryArgs;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterEnum
2+
ALTER TYPE "Reimbursement_Status_Type" ADD VALUE 'DENIED';

src/backend/src/prisma/migrations/20231024124220_add_bom/migration.sql renamed to src/backend/src/prisma/migrations/20231119054311_add_bom/migration.sql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ CREATE TABLE "Material" (
5151
CREATE TABLE "Material_Type" (
5252
"name" TEXT NOT NULL,
5353
"dateCreated" TIMESTAMP(3) NOT NULL,
54+
"dateDeleted" TIMESTAMP(3),
5455
"creatorId" INTEGER NOT NULL,
5556

5657
CONSTRAINT "Material_Type_pkey" PRIMARY KEY ("name")
@@ -68,9 +69,6 @@ CREATE TABLE "Manufacturer" (
6869
-- CreateIndex
6970
CREATE UNIQUE INDEX "Assembly_name_key" ON "Assembly"("name");
7071

71-
-- CreateIndex
72-
CREATE UNIQUE INDEX "Material_name_key" ON "Material"("name");
73-
7472
-- AddForeignKey
7573
ALTER TABLE "Assembly" ADD CONSTRAINT "Assembly_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE;
7674

src/backend/src/prisma/schema.prisma

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ enum Reimbursement_Status_Type {
365365
SABO_SUBMITTED
366366
ADVISOR_APPROVED
367367
REIMBURSED
368+
DENIED
368369
}
369370

370371
model Reimbursement_Status {
@@ -491,7 +492,7 @@ model Material {
491492
materialId String @id @default(uuid())
492493
assembly Assembly? @relation(fields: [assemblyId], references: [assemblyId])
493494
assemblyId String?
494-
name String @unique
495+
name String
495496
wbsElement WBS_Element @relation(fields: [wbsElementId], references: [wbsElementId])
496497
wbsElementId Int
497498
dateDeleted DateTime?
@@ -519,6 +520,7 @@ model Material {
519520
model Material_Type {
520521
name String @id
521522
dateCreated DateTime
523+
dateDeleted DateTime?
522524
creatorId Int
523525
materials Material[]
524526
}

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

Lines changed: 145 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,70 @@ const wonderwoman: Prisma.UserCreateInput = {
6969
googleAuthId: 'wonderwoman'
7070
};
7171

72+
const lexLuther: Prisma.UserCreateInput = {
73+
firstName: 'Alexander',
74+
lastName: 'Luther',
75+
email: 'lexluther@justiceleague.com',
76+
googleAuthId: 'hjkklo',
77+
role: Role.MEMBER
78+
};
79+
80+
const hawkgirl: Prisma.UserCreateInput = {
81+
firstName: 'Shiera',
82+
lastName: 'Hall',
83+
email: 'hawkgirl@justiceleague.com',
84+
googleAuthId: 'bhuujki',
85+
role: Role.MEMBER
86+
};
87+
88+
const elongatedMan: Prisma.UserCreateInput = {
89+
firstName: 'Randolph',
90+
lastName: 'Dibney',
91+
email: 'elongatedmangit @justiceleague.com',
92+
googleAuthId: 'joigiug',
93+
role: Role.MEMBER
94+
};
95+
96+
const zatanna: Prisma.UserCreateInput = {
97+
firstName: 'Zatanna',
98+
lastName: 'Zatara',
99+
email: 'zatanna@justiceleague.com',
100+
googleAuthId: 'cawwww',
101+
role: Role.MEMBER
102+
};
103+
104+
const phantomStranger: Prisma.UserCreateInput = {
105+
firstName: 'Judas',
106+
lastName: 'Iscariot',
107+
email: 'phantomstranger@justiceleague.com',
108+
googleAuthId: 'bnhjiuy',
109+
role: Role.MEMBER
110+
};
111+
112+
const redTornado: Prisma.UserCreateInput = {
113+
firstName: 'Red',
114+
lastName: 'Tornado',
115+
email: 'redtornado@justiceleague.com',
116+
googleAuthId: 'vbnhught',
117+
role: Role.MEMBER
118+
};
119+
120+
const firestorm: Prisma.UserCreateInput = {
121+
firstName: 'Ronnie',
122+
lastName: 'Raymond',
123+
email: 'firestorm@justiceleague.com',
124+
googleAuthId: 'fghttyu',
125+
role: Role.MEMBER
126+
};
127+
128+
const hankHeywood: Prisma.UserCreateInput = {
129+
firstName: 'Hank',
130+
lastName: 'Heywood III',
131+
email: 'hankheywood@justiceleague.com',
132+
googleAuthId: 'hudhsgf',
133+
role: Role.MEMBER
134+
};
135+
72136
const flash: Prisma.UserCreateInput = {
73137
firstName: 'Barry',
74138
lastName: 'Allen',
@@ -572,13 +636,85 @@ const babyDollJacobson: Prisma.UserCreateInput = {
572636
role: Role.LEADERSHIP
573637
};
574638

639+
const frostBite: Prisma.UserCreateInput = {
640+
firstName: 'Frost',
641+
lastName: 'Bite',
642+
googleAuthId: 'husky1',
643+
email: 'frostbite@northeastern.edu',
644+
role: Role.MEMBER
645+
};
646+
647+
const winter: Prisma.UserCreateInput = {
648+
firstName: 'Winter',
649+
lastName: 'Warrior',
650+
googleAuthId: 'husky2',
651+
email: 'winterwarrior@northeastern.edu',
652+
role: Role.MEMBER
653+
};
654+
655+
const paws: Prisma.UserCreateInput = {
656+
firstName: 'Paws',
657+
lastName: 'The-Dog',
658+
googleAuthId: 'husky3',
659+
email: 'paws@northeastern.edu',
660+
role: Role.MEMBER
661+
};
662+
663+
const snowPaws: Prisma.UserCreateInput = {
664+
firstName: 'Snow',
665+
lastName: 'Paws',
666+
googleAuthId: 'husky4',
667+
email: 'snowpaws@northeastern.edu',
668+
role: Role.MEMBER
669+
};
670+
671+
const whiteTail: Prisma.UserCreateInput = {
672+
firstName: 'White',
673+
lastName: 'Tail',
674+
googleAuthId: 'husky5',
675+
email: 'whitetail@northeastern.edu',
676+
role: Role.MEMBER
677+
};
678+
679+
const husky: Prisma.UserCreateInput = {
680+
firstName: 'Husky',
681+
lastName: 'Dog',
682+
googleAuthId: 'husky6',
683+
email: 'huskydog@northeastern.edu',
684+
role: Role.MEMBER
685+
};
686+
687+
const howler: Prisma.UserCreateInput = {
688+
firstName: 'Howler',
689+
lastName: 'Husky',
690+
googleAuthId: 'husky7',
691+
email: 'howler@northeastern.edu',
692+
role: Role.MEMBER
693+
};
694+
695+
const snowBite: Prisma.UserCreateInput = {
696+
firstName: 'Snow',
697+
lastName: 'Bite',
698+
googleAuthId: 'husky8',
699+
email: 'SnowBite@northeastern.edu',
700+
role: Role.MEMBER
701+
};
702+
575703
export const dbSeedAllUsers = {
576704
thomasEmrax,
577705
joeShmoe,
578706
joeBlow,
579707
wonderwoman,
580708
flash,
581709
aquaman,
710+
lexLuther,
711+
hawkgirl,
712+
elongatedMan,
713+
zatanna,
714+
phantomStranger,
715+
redTornado,
716+
firestorm,
717+
hankHeywood,
582718
robin,
583719
batman,
584720
superman,
@@ -637,5 +773,13 @@ export const dbSeedAllUsers = {
637773
kenWilliams,
638774
boogPowell,
639775
mannyMachado,
640-
babyDollJacobson
776+
babyDollJacobson,
777+
frostBite,
778+
winter,
779+
snowPaws,
780+
paws,
781+
whiteTail,
782+
husky,
783+
howler,
784+
snowBite
641785
};

0 commit comments

Comments
 (0)