Skip to content

Commit

Permalink
fix: properly check for whatPages
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Nov 4, 2023
1 parent 90e9127 commit 5d4e16d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { makeUnitName } from "lib/utils";
import type { GetMyDeputiesData, PutDispatchStatusByUnitId } from "@snailycad/types/api";
import type { EmergencyVehicleValue } from "@snailycad/types";
import { Permissions, usePermission } from "hooks/usePermission";
import { handleWhatPagesFilter } from "components/shared/utility-panel/statuses-area";

export function SelectDeputyModal() {
const setActiveDeputy = useEmsFdState((state) => state.setActiveDeputy);
Expand All @@ -28,7 +29,7 @@ export function SelectDeputyModal() {

const { codes10 } = useValues();
const onDutyCode = codes10.values.find(
(v) => v.shouldDo === ShouldDoType.SET_ON_DUTY && v.whatPages.includes(WhatPages.EMS_FD),
(v) => v.shouldDo === ShouldDoType.SET_ON_DUTY && handleWhatPagesFilter(v, WhatPages.EMS_FD),
);

const { hasPermissions } = usePermission();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type { GetMyOfficersData, PutDispatchStatusByUnitId } from "@snailycad/ty
import { useDispatchState } from "state/dispatch/dispatch-state";
import { Permissions, usePermission } from "hooks/usePermission";
import { ValueSelectField } from "components/form/inputs/value-select-field";
import { handleWhatPagesFilter } from "components/shared/utility-panel/statuses-area";

export function SelectOfficerModal() {
const setActiveOfficer = useLeoState((state) => state.setActiveOfficer);
Expand All @@ -42,7 +43,7 @@ export function SelectOfficerModal() {

const { codes10 } = useValues();
const onDutyCode = codes10.values.find(
(v) => v.shouldDo === ShouldDoType.SET_ON_DUTY && v.whatPages.includes(WhatPages.LEO),
(v) => v.shouldDo === ShouldDoType.SET_ON_DUTY && handleWhatPagesFilter(v, WhatPages.LEO),
);
const { state, execute } = useFetch();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export function StatusesArea<T extends ActiveOfficer | ActiveDeputy>({
);
}

function handleWhatPagesFilter(status: StatusValue, whatPagesType: WhatPages) {
export function handleWhatPagesFilter(status: StatusValue, whatPagesType: WhatPages) {
if (status.whatPages.length <= 0) return true;
return status.whatPages.includes(whatPagesType);
}

0 comments on commit 5d4e16d

Please sign in to comment.