Skip to content

Commit

Permalink
feat: able to assign/unassign
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Sep 27, 2023
1 parent e9a979f commit 2f3d85b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export class IncidentController {
}

@Post("/:type/:incidentId")
@Description("Assign or unassign a unit from an Active Incident")
@UsePermissions({
permissions: [Permissions.Dispatch, Permissions.Leo, Permissions.EmsFd],
})
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 @@ -346,7 +346,9 @@
"layoutSavedMessage": "Your layout has been saved.",
"editDashboardLayout": "Edit Dashboard Layout",
"vehicleInvolved": "Vehicle Involved",
"fireType": "Fire Type"
"fireType": "Fire Type",
"unassignFromIncident": "Unassign from incident",
"assignToIncident": "Assign to incident"
},
"Bolos": {
"activeBolos": "Active Bolos",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export function ActiveIncidents() {
description: <CallDescription data={incident} />,
actions: (
<ActiveIncidentsActionsColumn
handleAssignUnassignToIncident={handleAssignUnassignToIncident}
setTempIncident={setTempIncident}
unit={activeUnitForRoute}
isUnitAssigned={isUnitAssigned}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ interface Props {
unit: ActiveOfficer | ActiveDeputy | null;
isUnitAssigned: boolean;
setTempIncident(incident: LeoIncident): void;

// handleAssignUnassignToCall(call: Full911Call, type: "assign" | "unassign"): void;
handleAssignUnassignToIncident(
incident: LeoIncident,
unitId: string,
type: "assign" | "unassign",
): void;
}

export function ActiveIncidentsActionsColumn({
setTempIncident,
handleAssignUnassignToIncident,
isUnitAssigned,
unit,
incident,
Expand All @@ -30,7 +34,7 @@ export function ActiveIncidentsActionsColumn({
const { hasPermissions } = usePermission();
const router = useRouter();

const t = useTranslations("Calls");
const t = useTranslations("Leo");
const common = useTranslations("Common");

const hasDispatchPermissions = hasPermissions(defaultPermissions.defaultDispatchPermissions);
Expand Down Expand Up @@ -69,17 +73,23 @@ export function ActiveIncidentsActionsColumn({
>
{t("end")}
</Button>
) : // <Button
// className="ml-2"
// disabled={!isUnitActive}
// size="xs"
// onPress={() =>
// handleAssignUnassignToCall(incident, isUnitAssigned ? "unassign" : "assign")
// }
// >
// {isUnitAssigned ? t("unassignFromIncident") : t("assignToIncident")}
// </Button>
null}
) : (
<Button
className="ml-2"
disabled={!isUnitActive}
size="xs"
onPress={() =>
unit &&
handleAssignUnassignToIncident(
incident,
unit.id,
isUnitAssigned ? "unassign" : "assign",
)
}
>
{isUnitAssigned ? t("unassignFromIncident") : t("assignToIncident")}
</Button>
)}
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,6 @@ export function ManageIncidentModal<T extends LeoIncident | EmsFdIncident>({
activeUnit,
});

console.log({
hasActiveDispatchers,
isDispatch,
isReadOnly,
areFieldsDisabled,
});

function handleAddUpdateCallEvent(incident: LeoIncident) {
setActiveIncidents(activeIncidents.map((inc) => (inc.id === incident.id ? incident : inc)));
}
Expand Down

0 comments on commit 2f3d85b

Please sign in to comment.