Skip to content

Commit

Permalink
feat: extended EMS/FD incidents
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Sep 25, 2023
1 parent cf46762 commit 19fe35b
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- AlterTable
ALTER TABLE "EmsFdIncident" ADD COLUMN "address" TEXT,
ADD COLUMN "fireType" TEXT,
ADD COLUMN "vehicleInvolved" BOOLEAN NOT NULL DEFAULT false;
3 changes: 3 additions & 0 deletions apps/api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -1588,14 +1588,17 @@ model EmsFdIncident {
caseNumber Int @default(autoincrement())
description String? @db.Text
descriptionData Json?
address String?
postal String?
fireType String?
// when null, it is the dispatcher
creator EmsFdDeputy? @relation("emsFdIncidentCreator", fields: [creatorId], references: [id])
creatorId String?
unitsInvolved IncidentInvolvedUnit[] @relation("unitsInvolved")
firearmsInvolved Boolean @default(false)
injuriesOrFatalities Boolean @default(false)
arrestsMade Boolean @default(false)
vehicleInvolved Boolean @default(false)
isActive Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
Expand Down
4 changes: 3 additions & 1 deletion apps/client/locales/en/leo.json
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@
"ACTIVE_INCIDENTS": "Active Incidents",
"layoutSavedTitle": "Layout Saved",
"layoutSavedMessage": "Your layout has been saved.",
"editDashboardLayout": "Edit Dashboard Layout"
"editDashboardLayout": "Edit Dashboard Layout",
"vehicleInvolved": "Vehicle Involved",
"fireType": "Fire Type"
},
"Bolos": {
"activeBolos": "Active Bolos",
Expand Down
60 changes: 45 additions & 15 deletions apps/client/src/components/leo/incidents/manage-incident-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
FormRow,
Infofield,
FullDate,
TextField,
} from "@snailycad/ui";
import { FormField } from "components/form/FormField";
import { Modal } from "components/modal/Modal";
Expand Down Expand Up @@ -160,16 +161,20 @@ export function ManageIncidentModal<T extends LeoIncident | EmsFdIncident>({
}

const validate = handleValidate(LEO_INCIDENT_SCHEMA);
const isEmsFdIncident = incident && "fireType" in incident;

const INITIAL_VALUES = {
description: incident?.description ?? "",
postal: incident?.postal ?? "",
descriptionData: dataToSlate(incident),
vehicleInvolved: isEmsFdIncident ? incident.vehicleInvolved : false,
firearmsInvolved: incident?.firearmsInvolved ?? false,
injuriesOrFatalities: incident?.injuriesOrFatalities ?? false,
arrestsMade: incident?.arrestsMade ?? false,
isActive: isDispatch ? true : incident?.isActive ?? false,
situationCodeId: incident?.situationCodeId ?? null,
openModalAfterCreation: true,
fireType: isEmsFdIncident ? incident.fireType ?? "" : "",
};

return (
Expand Down Expand Up @@ -205,7 +210,12 @@ export function ManageIncidentModal<T extends LeoIncident | EmsFdIncident>({
) : null}

<div>
<FormRow className="mb-3" useFlex>
<div
className={classNames(
"grid mb-3",
type === "ems-fd" ? "grid-cols-2" : "grid-cols-3",
)}
>
<SwitchField
isDisabled={areFieldsDisabled}
isSelected={values.firearmsInvolved}
Expand All @@ -232,7 +242,16 @@ export function ManageIncidentModal<T extends LeoIncident | EmsFdIncident>({
>
{t("arrestsMade")}
</SwitchField>
</FormRow>

<SwitchField
isDisabled={areFieldsDisabled}
isSelected={values.vehicleInvolved}
onChange={(isSelected) => setFieldValue("vehicleInvolved", isSelected)}
className="w-full"
>
{t("vehicleInvolved")}
</SwitchField>
</div>

<FormField errorMessage={errors.description} label={common("description")}>
<Editor
Expand All @@ -242,22 +261,33 @@ export function ManageIncidentModal<T extends LeoIncident | EmsFdIncident>({
/>
</FormField>

<FormRow useFlex>
<ValueSelectField
className="w-full"
isOptional
isDisabled={areFieldsDisabled}
isClearable
label={t("situationCode")}
fieldName="situationCodeId"
values={codes10.values}
valueType={ValueType.CODES_10}
filterFn={(value) => value.type === StatusValueType.SITUATION_CODE}
/>
<FormRow useFlex className={classNames(type === "ems-fd" && "!flex-col")}>
<FormRow useFlex className={classNames(type === "leo" && "!flex-col")}>
<ValueSelectField
className="w-full"
isOptional
isDisabled={areFieldsDisabled}
isClearable
label={t("situationCode")}
fieldName="situationCodeId"
values={codes10.values}
valueType={ValueType.CODES_10}
filterFn={(value) => value.type === StatusValueType.SITUATION_CODE}
/>

<TextField
isOptional
value={values.fireType}
className="w-full"
onChange={(value) => setFieldValue("fireType", value)}
label={t("fireType")}
/>
</FormRow>

<AddressPostalSelect
addressOptional
isDisabled={areFieldsDisabled}
postalOnly
postalOnly={type === "leo"}
addressLabel="location"
/>
</FormRow>
Expand Down

0 comments on commit 19fe35b

Please sign in to comment.