From 6d5ca51cbf810807b36efae7e9e7f5ca9b36a01a Mon Sep 17 00:00:00 2001 From: Dev-CasperTheGhost <53900565+Dev-CasperTheGhost@users.noreply.github.com> Date: Wed, 17 Nov 2021 16:59:49 +0100 Subject: [PATCH] :tada: set status to ASSIGNED (closes #156) --- .../controllers/dispatch/Calls911Controller.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/api/src/controllers/dispatch/Calls911Controller.ts b/packages/api/src/controllers/dispatch/Calls911Controller.ts index 63f809b85..08412f525 100644 --- a/packages/api/src/controllers/dispatch/Calls911Controller.ts +++ b/packages/api/src/controllers/dispatch/Calls911Controller.ts @@ -353,6 +353,22 @@ export class Calls911Controller { throw new BadRequest("unitOffDuty"); } + const status = await prisma.statusValue.findFirst({ + where: { shouldDo: "SET_ASSIGNED" }, + }); + + if (status) { + const t = type === "leo" ? "officer" : "emsFdDeputy"; + // @ts-expect-error ignore + await prisma[t].update({ + where: { id: unit.id }, + data: { statusId: status.id }, + }); + + this.socket.emitUpdateOfficerStatus(); + this.socket.emitUpdateDeputyStatus(); + } + const assignedUnit = await prisma.assignedUnit.create({ data: { call911Id: callId,