diff --git a/packages/api/src/controllers/dispatch/Calls911Controller.ts b/packages/api/src/controllers/dispatch/Calls911Controller.ts index b5fb6397d..ab368ff43 100644 --- a/packages/api/src/controllers/dispatch/Calls911Controller.ts +++ b/packages/api/src/controllers/dispatch/Calls911Controller.ts @@ -171,7 +171,7 @@ export class Calls911Controller { @UseBefore(IsDispatch) @Delete("/:id") - async end911Call(@PathParams("id") id: string, @BodyParams() body: JsonRequestBody) { + async end911Call(@PathParams("id") id: string) { const call = await prisma.call911.findUnique({ where: { id }, }); @@ -180,21 +180,12 @@ export class Calls911Controller { throw new NotFound("callNotFound"); } - const event = await prisma.call911Event.create({ - data: { - call911Id: call.id, - description: body.get("description"), - }, - }); - - // todo: update sockets - - return event; + return true; } @UseBefore(IsDispatch) @Post("/events/:callId") - async createCallEvent(@PathParams("callId") callId: string) { + async createCallEvent(@PathParams("callId") callId: string, @BodyParams() body: JsonRequestBody) { const call = await prisma.call911.findUnique({ where: { id: callId }, }); @@ -203,6 +194,15 @@ export class Calls911Controller { throw new NotFound("callNotFound"); } - return true; + const event = await prisma.call911Event.create({ + data: { + call911Id: call.id, + description: body.get("description"), + }, + }); + + this.socket.emitAddCallEvent(event); + + return event; } } diff --git a/packages/api/src/services/SocketService.ts b/packages/api/src/services/SocketService.ts index 195f00138..ff1ee8049 100644 --- a/packages/api/src/services/SocketService.ts +++ b/packages/api/src/services/SocketService.ts @@ -1,7 +1,7 @@ import { Nsp, SocketService } from "@tsed/socketio"; import * as SocketIO from "socket.io"; import { SocketEvents } from "@snailycad/config"; -import { Call911, TowCall, Bolo } from ".prisma/client"; +import { Call911, TowCall, Bolo, Call911Event } from ".prisma/client"; @SocketService("/") export class Socket { @@ -63,4 +63,8 @@ export class Socket { emitUserBanned(userId: string) { this.io.sockets.emit(SocketEvents.UserBanned, userId); } + + emitAddCallEvent(event: Call911Event) { + this.io.sockets.emit(SocketEvents.AddCallEvent, event); + } } diff --git a/packages/client/locales/en/calls.json b/packages/client/locales/en/calls.json index 908bf5ded..a339a25a7 100644 --- a/packages/client/locales/en/calls.json +++ b/packages/client/locales/en/calls.json @@ -12,11 +12,14 @@ "caller": "Caller", "createTowCall": "Create tow call", "createTaxiCall": "Create taxi call", + "create911Call": "Create 911 call", "editTowCall": "Edit tow call", "assignedUnits": "Assigned Units", "selectCitizen": "Select citizen", "endCall": "End Call", "end911Call": "End 911 Call", + "addEvent": "Add Event", + "noEvents": "This call does not have any events", "alert_end911Call": "Are you sure you want to end this call?", "alert_endTowCall": "Are you sure you want to end this call?" } diff --git a/packages/client/locales/en/common.json b/packages/client/locales/en/common.json index 7c615ddbd..dc495d4d4 100644 --- a/packages/client/locales/en/common.json +++ b/packages/client/locales/en/common.json @@ -23,7 +23,8 @@ "decline": "Decline", "createdAt": "Created At", "reset": "Reset", - "search": "Search" + "search": "Search", + "events": "Events" }, "Errors": { "unknown": "An unexpected error occurred", diff --git a/packages/client/src/components/dispatch/ModalButtons.tsx b/packages/client/src/components/dispatch/ModalButtons.tsx index 4738c3e53..849b12a7f 100644 --- a/packages/client/src/components/dispatch/ModalButtons.tsx +++ b/packages/client/src/components/dispatch/ModalButtons.tsx @@ -4,51 +4,67 @@ import { ModalIds } from "types/ModalIds"; import { useModal } from "context/ModalContext"; interface MButton { - nameKey: string; + nameKey: [string, string]; modalId: string; } const buttons: MButton[] = [ { - nameKey: "nameSearch", + nameKey: ["Leo", "nameSearch"], modalId: ModalIds.NameSearch, }, { - nameKey: "plateSearch", + nameKey: ["Leo", "plateSearch"], modalId: ModalIds.VehicleSearch, }, { - nameKey: "weaponSearch", + nameKey: ["Leo", "weaponSearch"], modalId: ModalIds.WeaponSearch, }, { - nameKey: "addressSearch", - modalId: ModalIds.AddressSearch, + nameKey: ["Leo", "createWrittenWarning"], + modalId: ModalIds.CreateWrittenWarning, }, { - nameKey: "createBolo", + nameKey: ["Leo", "createTicket"], + modalId: ModalIds.CreateTicket, + }, + { + nameKey: ["Leo", "createArrestReport"], + modalId: ModalIds.CreateArrestReport, + }, + { + nameKey: ["Leo", "createBolo"], modalId: ModalIds.ManageBolo, }, { - nameKey: "notepad", + nameKey: ["Calls", "create911Call"], + modalId: ModalIds.Manage911Call, + }, + { + nameKey: ["Leo", "notepad"], modalId: ModalIds.Notepad, }, + { + nameKey: ["Leo", "activeOfficers"], + modalId: ModalIds.ActiveOfficers, + }, ]; export const DispatchModalButtons = () => { const { openModal } = useModal(); - const t = useTranslations("Leo"); + const t = useTranslations(); return (