unit/#102-base-management #121

Merged
jkeffects merged 35 commits from unit/#102-base-management into milestone/ff-admin-unit 2025-07-14 13:36:35 +00:00
2 changed files with 13 additions and 13 deletions
Showing only changes of commit 0f3e4488f4 - Show all commits

View file

@ -51,8 +51,8 @@ export async function getAllInspectionPlans(req: Request, res: Response): Promis
* @returns {Promise<*>}
*/
export async function getAllInspectionPlansForRelated(req: Request, res: Response): Promise<any> {
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,

View file

@ -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);