Skip to content

Commit

Permalink
Merge pull request #2608 from Northeastern-Electric-Racing/Multitenan…
Browse files Browse the repository at this point in the history
…t-Bug-Fixes

Multitenant Bug Fixes
  • Loading branch information
Peyton-McKee authored May 26, 2024
2 parents ebb6565 + d26f322 commit 4bcccca
Show file tree
Hide file tree
Showing 171 changed files with 1,152 additions and 1,122 deletions.
25 changes: 23 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,32 @@
"version": "2.0.0",
"tasks": [
{
"label": "tsc watch",
"label": "tsc watch backend",
"type": "shell",
"command": "./node_modules/.bin/tsc",
"isBackground": true,
"args": ["--watch", "--noEmit", "--project", "./tsconfig.build.json"],
"args": ["--watch", "--noEmit", "--project", "./src/backend/tsconfig.json"],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "never",
"echo": false,
"focus": false,
"panel": "dedicated"
},
"problemMatcher": "$tsc-watch",
"runOptions": {
"runOn": "folderOpen"
}
},
{
"label": "tsc watch frontend",
"type": "shell",
"command": "./node_modules/.bin/tsc",
"isBackground": true,
"args": ["--watch", "--noEmit", "--project", "./src/frontend/tsconfig.json"],
"group": {
"kind": "build",
"isDefault": true
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
"build:frontend": "yarn workspace frontend build",
"build:frontend:dev": "yarn workspace frontend build:dev",
"i": "yarn install && yarn prisma:generate",
"database:setup": "yarn databse:setup:script && docker run --name finishline -e POSTGRES_PASSWORD=docker -p 5432:5432 -d postgres && sleep 5 && docker exec finishline psql -U postgres -c \"CREATE DATABASE nerpm;\" && yarn prisma:reset",
"database:setup": "yarn database:setup:script && docker run --name finishline -e POSTGRES_PASSWORD=docker -p 5432:5432 -d postgres && sleep 5 && docker exec finishline psql -U postgres -c \"CREATE DATABASE nerpm;\" && yarn prisma:reset",
"database:setup:script": "node scripts/database-setup.js",
"istart": "yarn i && yarn start",
"reset": "rimraf yarn.lock; rimraf src/frontend/node_modules; rimraf src/backend/node_modules; rimraf src/shared/node_modules; rimraf ./node_modules; ",
"install:hard": "yarn reset; yarn install; yarn prisma:generate",
"tsc-check": "tsc --noEmit --project tsconfig.build.json"
"tsc-check": "tsc --noEmit --project src/backend/tsconfig.json && tsc --noEmit --project src/frontend/tsconfig.json"
},
"resolutions": {
"@types/react": "17.0.1",
Expand Down
30 changes: 15 additions & 15 deletions src/backend/src/controllers/change-requests.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { getOrganizationId } from '../utils/utils';
export default class ChangeRequestsController {
static async getChangeRequestByID(req: Request, res: Response, next: NextFunction) {
try {
const crId: number = parseInt(req.params.crId);
const { crId } = req.params;
const organizationId = getOrganizationId(req.headers);

const cr = await ChangeRequestsService.getChangeRequestByID(crId, organizationId);
return res.status(200).json(cr);
res.status(200).json(cr);
} catch (error: unknown) {
next(error);
}
Expand All @@ -22,7 +22,7 @@ export default class ChangeRequestsController {
const organizationId = getOrganizationId(req.headers);

const changeRequests = await ChangeRequestsService.getAllChangeRequests(organizationId);
return res.status(200).json(changeRequests);
res.status(200).json(changeRequests);
} catch (error: unknown) {
next(error);
}
Expand All @@ -41,15 +41,15 @@ export default class ChangeRequestsController {
organizationId,
psId
);
return res.status(200).json({ message: `Change request #${id} successfully reviewed.` });
res.status(200).json({ message: `Change request #${id} successfully reviewed.` });
} catch (error: unknown) {
next(error);
}
}

static async createActivationChangeRequest(req: Request, res: Response, next: NextFunction) {
try {
const { wbsNum, type, projectLeadId, projectManagerId, startDate, confirmDetails } = req.body;
const { wbsNum, type, leadId, managerId, startDate, confirmDetails } = req.body;
const submitter = await getCurrentUser(res);
const organizationId = getOrganizationId(req.headers);

Expand All @@ -59,13 +59,13 @@ export default class ChangeRequestsController {
wbsNum.projectNumber,
wbsNum.workPackageNumber,
type,
projectLeadId,
projectManagerId,
leadId,
managerId,
startDate,
confirmDetails,
organizationId
);
return res.status(200).json({ message: `Successfully created activation change request with id #${id}` });
res.status(200).json({ message: `Successfully created activation change request with id #${id}` });
} catch (error: unknown) {
next(error);
}
Expand All @@ -85,7 +85,7 @@ export default class ChangeRequestsController {
confirmDone,
organizationId
);
return res.status(200).json({ message: `Successfully created stage gate request with id #${id}` });
res.status(200).json({ message: `Successfully created stage gate request with id #${id}` });
} catch (error: unknown) {
next(error);
}
Expand Down Expand Up @@ -113,7 +113,7 @@ export default class ChangeRequestsController {
projectProposedChanges,
workPackageProposedChanges
);
return res.status(200).json(createdCR);
res.status(200).json(createdCR);
} catch (error: unknown) {
next(error);
}
Expand All @@ -133,20 +133,20 @@ export default class ChangeRequestsController {
scopeImpact,
organizationId
);
return res.status(200).json({ message: `Successfully added proposed solution with id #${id}` });
res.status(200).json({ message: `Successfully added proposed solution with id #${id}` });
} catch (error: unknown) {
next(error);
}
}

static async deleteChangeRequest(req: Request, res: Response, next: NextFunction) {
try {
const crId: number = parseInt(req.params.crId);
const { crId } = req.params;
const user: User = await getCurrentUser(res);
const organizationId = getOrganizationId(req.headers);

await ChangeRequestsService.deleteChangeRequest(user, crId, organizationId);
return res.status(200).json({ message: `Successfully deleted change request #${crId}` });
res.status(200).json({ message: `Successfully deleted change request #${crId}` });
} catch (error: unknown) {
next(error);
}
Expand All @@ -155,12 +155,12 @@ export default class ChangeRequestsController {
static async requestCRReview(req: Request, res: Response, next: NextFunction) {
try {
const { userIds } = req.body;
const crId = parseInt(req.params.crId);
const { crId } = req.params;
const submitter: User = await getCurrentUser(res);
const organizationId = getOrganizationId(req.headers);

await ChangeRequestsService.requestCRReview(submitter, userIds, crId, organizationId);
return res.status(200).json({ message: `Successfully requested reviewer(s) to change request #${crId}` });
res.status(200).json({ message: `Successfully requested reviewer(s) to change request #${crId}` });
} catch (error: unknown) {
next(error);
}
Expand Down
12 changes: 6 additions & 6 deletions src/backend/src/controllers/design-reviews.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class DesignReviewsController {
try {
const organizationId = getOrganizationId(req.headers);
const designReviews = await DesignReviewsService.getAllDesignReviews(organizationId);
return res.status(200).json(designReviews);
res.status(200).json(designReviews);
} catch (error: unknown) {
next(error);
}
Expand All @@ -21,7 +21,7 @@ export default class DesignReviewsController {
const user: User = await getCurrentUser(res);
const organizationId = getOrganizationId(req.headers);
const deletedDesignReview = await DesignReviewsService.deleteDesignReview(user, drId, organizationId);
return res.status(200).json(deletedDesignReview);
res.status(200).json(deletedDesignReview);
} catch (error: unknown) {
next(error);
}
Expand All @@ -43,7 +43,7 @@ export default class DesignReviewsController {
meetingTimes,
organizationId
);
return res.status(200).json(createdDesignReview);
res.status(200).json(createdDesignReview);
} catch (error: unknown) {
next(error);
}
Expand All @@ -56,7 +56,7 @@ export default class DesignReviewsController {
const organizationId = getOrganizationId(req.headers);

const designReview = await DesignReviewsService.getSingleDesignReview(user, drId, organizationId);
return res.status(200).json(designReview);
res.status(200).json(designReview);
} catch (error: unknown) {
next(error);
}
Expand Down Expand Up @@ -103,7 +103,7 @@ export default class DesignReviewsController {
meetingTimes,
organizationId
);
return res.status(200).json({ message: 'Design Review updated successfully' });
res.status(200).json({ message: 'Design Review updated successfully' });
} catch (error: unknown) {
next(error);
}
Expand All @@ -123,7 +123,7 @@ export default class DesignReviewsController {
user,
organizationId
);
return res.status(200).json(updatedDesignReview);
res.status(200).json(updatedDesignReview);
} catch (error: unknown) {
next(error);
}
Expand Down
30 changes: 14 additions & 16 deletions src/backend/src/controllers/projects.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class ProjectsController {
try {
const organizationId = getOrganizationId(req.headers);
const projects: Project[] = await ProjectsService.getAllProjects(organizationId);
return res.status(200).json(projects);
res.status(200).json(projects);
} catch (error: unknown) {
next(error);
}
Expand All @@ -24,7 +24,7 @@ export default class ProjectsController {

const project: Project = await ProjectsService.getSingleProject(wbsNumber, organizationId);

return res.status(200).json(project);
res.status(200).json(project);
} catch (error: unknown) {
next(error);
}
Expand All @@ -33,8 +33,7 @@ export default class ProjectsController {
static async createProject(req: Request, res: Response, next: NextFunction) {
try {
const user: User = await getCurrentUser(res);
const { name, crId, carNumber, teamIds, budget, summary, projectLeadId, projectManagerId, links, descriptionBullets } =
req.body;
const { name, crId, carNumber, teamIds, budget, summary, leadId, managerId, links, descriptionBullets } = req.body;
const organizationId = getOrganizationId(req.headers);

const createdProject = await ProjectsService.createProject(
Expand All @@ -47,12 +46,12 @@ export default class ProjectsController {
budget,
links,
descriptionBullets,
projectLeadId,
projectManagerId,
leadId,
managerId,
organizationId
);

return res.status(200).json(createdProject);
res.status(200).json(createdProject);
} catch (error: unknown) {
next(error);
}
Expand All @@ -61,8 +60,7 @@ export default class ProjectsController {
static async editProject(req: Request, res: Response, next: NextFunction) {
try {
const user = await getCurrentUser(res);
const { projectId, crId, name, budget, summary, descriptionBullets, links, projectLeadId, projectManagerId } =
req.body;
const { projectId, crId, name, budget, summary, descriptionBullets, links, leadId, managerId } = req.body;
const organizationId = getOrganizationId(req.headers);

const editedProject: Project = await ProjectsService.editProject(
Expand All @@ -74,12 +72,12 @@ export default class ProjectsController {
summary,
descriptionBullets,
links,
projectLeadId || null,
projectManagerId || null,
leadId || null,
managerId || null,
organizationId
);

return res.status(200).json(editedProject);
res.status(200).json(editedProject);
} catch (error: unknown) {
next(error);
}
Expand All @@ -94,7 +92,7 @@ export default class ProjectsController {

await ProjectsService.setProjectTeam(user, wbsNumber, teamId, organizationId);

return res.status(200).json({ message: `Project ${wbsPipe(wbsNumber)}'s teams successfully updated.` });
res.status(200).json({ message: `Project ${wbsPipe(wbsNumber)}'s teams successfully updated.` });
} catch (error: unknown) {
next(error);
}
Expand Down Expand Up @@ -204,7 +202,7 @@ export default class ProjectsController {
pdmFileName,
unitName
);
return res.status(200).json(material);
res.status(200).json(material);
} catch (error: unknown) {
next(error);
}
Expand Down Expand Up @@ -255,7 +253,7 @@ export default class ProjectsController {
const organizationId = getOrganizationId(req.headers);

const manufacturers: Manufacturer[] = await BillOfMaterialsService.getAllManufacturers(user, organizationId);
return res.status(200).json(manufacturers);
res.status(200).json(manufacturers);
} catch (error: unknown) {
next(error);
}
Expand All @@ -267,7 +265,7 @@ export default class ProjectsController {
const organizationId = getOrganizationId(req.headers);

const materialTypes: MaterialType[] = await BillOfMaterialsService.getAllMaterialTypes(user, organizationId);
return res.status(200).json(materialTypes);
res.status(200).json(materialTypes);
} catch (error: unknown) {
next(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class ReimbursementRequestsController {
const organizationId = getOrganizationId(req.headers);

const vendors: Vendor[] = await ReimbursementRequestService.getAllVendors(organizationId);
return res.status(200).json(vendors);
res.status(200).json(vendors);
} catch (error: unknown) {
next(error);
}
Expand Down Expand Up @@ -184,7 +184,7 @@ export default class ReimbursementRequestsController {
user,
organizationId
);
return res.status(200).json(requestsPendingAdvisors);
res.status(200).json(requestsPendingAdvisors);
} catch (error: unknown) {
next(error);
}
Expand Down
Loading

0 comments on commit 4bcccca

Please sign in to comment.