diff --git a/apps/api/src/controllers/ems-fd/incidents/ems-fd-incidents-controller.ts b/apps/api/src/controllers/ems-fd/incidents/ems-fd-incidents-controller.ts index 8d89382b3..10b455426 100644 --- a/apps/api/src/controllers/ems-fd/incidents/ems-fd-incidents-controller.ts +++ b/apps/api/src/controllers/ems-fd/incidents/ems-fd-incidents-controller.ts @@ -4,7 +4,7 @@ import { NotFound, InternalServerError, BadRequest } from "@tsed/exceptions"; import { QueryParams, BodyParams, Context, PathParams } from "@tsed/platform-params"; import { prisma } from "lib/data/prisma"; import { IsAuth } from "middlewares/auth/is-auth"; -import { LEO_INCIDENT_SCHEMA } from "@snailycad/schemas"; +import { EMS_FD_INCIDENT_SCHEMA } from "@snailycad/schemas"; import { Officer, MiscCadSettings, CombinedLeoUnit } from "@prisma/client"; import { validateSchema } from "lib/data/validate-schema"; import { Socket } from "services/socket-service"; @@ -117,7 +117,7 @@ export class IncidentController { @Context("activeOfficer") activeOfficer: (CombinedLeoUnit & { officers: Officer[] }) | Officer, @Context("sessionUserId") sessionUserId: string, ): Promise> { - const data = validateSchema(LEO_INCIDENT_SCHEMA, body); + const data = validateSchema(EMS_FD_INCIDENT_SCHEMA, body); const officer = getUserOfficerFromActiveOfficer({ userId: sessionUserId, allowDispatch: true, @@ -136,6 +136,8 @@ export class IncidentController { isActive: data.isActive ?? false, situationCodeId: data.situationCodeId ?? null, postal: data.postal ?? null, + address: data.address ?? null, + fireType: data.fireType ?? null, }, include: { unitsInvolved: true, @@ -282,7 +284,7 @@ export class IncidentController { @Context("cad") cad: { miscCadSettings: MiscCadSettings }, @PathParams("id") incidentId: string, ): Promise> { - const data = validateSchema(LEO_INCIDENT_SCHEMA, body); + const data = validateSchema(EMS_FD_INCIDENT_SCHEMA, body); const maxAssignmentsToIncidents = cad.miscCadSettings.maxAssignmentsToIncidents ?? Infinity; const incident = await prisma.emsFdIncident.findUnique({ @@ -305,6 +307,8 @@ export class IncidentController { isActive: data.isActive ?? false, postal: data.postal ?? null, situationCodeId: data.situationCodeId ?? null, + address: data.address ?? null, + fireType: data.fireType ?? null, }, }); diff --git a/apps/client/src/components/leo/incidents/manage-incident-modal.tsx b/apps/client/src/components/leo/incidents/manage-incident-modal.tsx index 20aa72a48..07b5947c8 100644 --- a/apps/client/src/components/leo/incidents/manage-incident-modal.tsx +++ b/apps/client/src/components/leo/incidents/manage-incident-modal.tsx @@ -1,4 +1,4 @@ -import { LEO_INCIDENT_SCHEMA } from "@snailycad/schemas"; +import { EMS_FD_INCIDENT_SCHEMA, LEO_INCIDENT_SCHEMA } from "@snailycad/schemas"; import { Loader, Button, @@ -160,12 +160,13 @@ export function ManageIncidentModal({ } } - const validate = handleValidate(LEO_INCIDENT_SCHEMA); + const validate = handleValidate(type === "ems-fd" ? EMS_FD_INCIDENT_SCHEMA : LEO_INCIDENT_SCHEMA); const isEmsFdIncident = incident && "fireType" in incident; const INITIAL_VALUES = { description: incident?.description ?? "", postal: incident?.postal ?? "", + address: isEmsFdIncident ? incident.address : "", descriptionData: dataToSlate(incident), vehicleInvolved: isEmsFdIncident ? incident.vehicleInvolved : false, firearmsInvolved: incident?.firearmsInvolved ?? false, @@ -292,7 +293,7 @@ export function ManageIncidentModal({ addressOptional isDisabled={areFieldsDisabled} postalOnly={type === "leo"} - addressLabel="location" + addressLabel="address" /> diff --git a/packages/schemas/src/leo.ts b/packages/schemas/src/leo.ts index c37211375..0edaab829 100644 --- a/packages/schemas/src/leo.ts +++ b/packages/schemas/src/leo.ts @@ -85,6 +85,11 @@ export const LEO_INCIDENT_SCHEMA = z.object({ situationCodeId: z.string().max(255).nullish(), }); +export const EMS_FD_INCIDENT_SCHEMA = LEO_INCIDENT_SCHEMA.extend({ + address: z.string().nullish(), + fireType: z.string().nullish(), +}); + export const LEO_VEHICLE_LICENSE_SCHEMA = VEHICLE_SCHEMA.pick({ inspectionStatus: true, insuranceStatus: true,