From 0f3e4488f4f0cb5c6ac8503e58c91f7194c5d0e4 Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Fri, 11 Jul 2025 09:42:04 +0200 Subject: [PATCH] correct type inspectionPlans request --- .../admin/unit/inspectionPlanController.ts | 14 +++++++------- src/routes/admin/unit/inspectionPlan.ts | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/controller/admin/unit/inspectionPlanController.ts b/src/controller/admin/unit/inspectionPlanController.ts index 69e3e1e..1165485 100644 --- a/src/controller/admin/unit/inspectionPlanController.ts +++ b/src/controller/admin/unit/inspectionPlanController.ts @@ -51,8 +51,8 @@ export async function getAllInspectionPlans(req: Request, res: Response): Promis * @returns {Promise<*>} */ export async function getAllInspectionPlansForRelated(req: Request, res: Response): Promise { - let relation = req.params.related as "vehicle" | "equipment" | "wearable"; - let relationId = req.params.relatedId as string; + let relation = req.params.related as "vehicleType" | "equipmentType" | "wearableType"; + let relationTypeId = req.params.relatedTypeId as string; let offset = parseInt((req.query.offset as string) ?? "0"); let count = parseInt((req.query.count as string) ?? "25"); let search = (req.query.search as string) ?? ""; @@ -60,12 +60,12 @@ export async function getAllInspectionPlansForRelated(req: Request, res: Respons let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i); let where; - if (relation == "equipment") { - where = { equipmentTypeId: relationId }; - } else if (relation == "vehicle") { - where = { vehicleTypeId: relationId }; + if (relation == "equipmentType") { + where = { equipmentTypeId: relationTypeId }; + } else if (relation == "vehicleType") { + where = { vehicleTypeId: relationTypeId }; } else { - where = { wearableTypeId: relationId }; + where = { wearableTypeId: relationTypeId }; } let [inspectionPlans, total] = await InspectionPlanService.getAllForRelated(where, { offset, diff --git a/src/routes/admin/unit/inspectionPlan.ts b/src/routes/admin/unit/inspectionPlan.ts index 4fbab19..914d9d3 100644 --- a/src/routes/admin/unit/inspectionPlan.ts +++ b/src/routes/admin/unit/inspectionPlan.ts @@ -22,14 +22,14 @@ router.get("/:id/points", async (req: Request, res: Response) => { }); router.get( - ["/vehicle/:relatedId", "/equipment/:relatedId", "/wearable/:relatedId"], + ["/vehicleType/:relatedTypeId", "/equipmentType/:relatedTypeId", "/wearableType/:relatedTypeId"], async (req: Request, res: Response) => { - if (req.path.startsWith("/vehicle")) { - req.params.related = "vehicle"; - } else if (req.path.startsWith("/equipment")) { - req.params.related = "equipment"; + if (req.path.startsWith("/vehicleType")) { + req.params.related = "vehicleType"; + } else if (req.path.startsWith("/equipmentType")) { + req.params.related = "equipmentType"; } else { - req.params.related = "wearable"; + req.params.related = "wearableType"; } await getAllInspectionPlansForRelated(req, res);