Skip to content

Commit

Permalink
feat: can only update table number once
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrastopoulos committed Feb 6, 2025
1 parent 9f77d70 commit e27742b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/controllers/ProjectsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const createNewProject = async (
}
};

export const editProject = async (
export const saveProject = async (
req: Request,
res: Response
): Promise<void> => {
Expand Down Expand Up @@ -461,6 +461,10 @@ export const updateProjectTableNumber = async (
return notFound(res, "Project not found");
}

if (project.tableNumber) {
return bad(res, "Project already has a table number");
}

await project.updateOne({
$set: { tableNumber },
});
Expand Down
4 changes: 2 additions & 2 deletions src/routes/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import express, { Router } from "express";
import {
createNewProject,
deleteProject,
editProject,
saveProject,
enterProject,
getAllProjects,
getProjectByID,
Expand Down Expand Up @@ -145,7 +145,7 @@ router.post("/", isAuthenticated, asyncCatch(createNewProject));
* 500:
* description: Internal Server Error.
*/
router.patch("/:id", isProjectOwnerOrAdmin, asyncCatch(editProject));
router.patch("/:id", isProjectOwnerOrAdmin, asyncCatch(saveProject));

/**
* @swagger
Expand Down

0 comments on commit e27742b

Please sign in to comment.