Skip to content

Commit

Permalink
fix: flasing of active officers on EMS/FD page
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Sep 15, 2023
1 parent e77255f commit 6dcf584
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions apps/client/src/pages/ems-fd/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { useTones } from "hooks/global/use-tones";
import { useLoadValuesClientSide } from "hooks/useLoadValuesClientSide";
import type {
Get911CallsData,
GetActiveOfficersData,
GetEmsFdActiveDeputies,
GetEmsFdActiveDeputy,
} from "@snailycad/types/api";
Expand All @@ -35,6 +36,7 @@ import { ModalIds } from "types/modal-ids";
interface Props {
activeDeputy: GetEmsFdActiveDeputy | null;
activeDeputies: GetEmsFdActiveDeputies;
activeOfficers: GetActiveOfficersData;
calls: Get911CallsData;
}

Expand Down Expand Up @@ -73,7 +75,12 @@ const DepartmentInfoModal = dynamic(async () => {
return (await import("components/leo/modals/department-info-modal")).DepartmentInformationModal;
});

export default function EmsFDDashboard({ activeDeputy, calls, activeDeputies }: Props) {
export default function EmsFDDashboard({
activeDeputy,
calls,
activeOfficers,
activeDeputies,
}: Props) {
useLoadValuesClientSide({
valueTypes: [
ValueType.BLOOD_GROUP,
Expand All @@ -99,6 +106,7 @@ export default function EmsFDDashboard({ activeDeputy, calls, activeDeputies }:
state.setActiveDeputy(activeDeputy);
set911Calls(calls.calls);
dispatchState.setActiveDeputies(activeDeputies);
dispatchState.setActiveOfficers(activeOfficers);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [activeDeputies, activeDeputy, calls]);

Expand Down Expand Up @@ -130,7 +138,7 @@ export default function EmsFDDashboard({ activeDeputy, calls, activeDeputies }:
<div className="w-full">{CALLS_911 ? <ActiveCalls initialData={calls} /> : null}</div>
</div>
<div className="mt-3">
<ActiveOfficers initialOfficers={[]} />
<ActiveOfficers initialOfficers={activeOfficers} />
<ActiveDeputies initialDeputies={activeDeputies} />
</div>

Expand All @@ -155,18 +163,20 @@ export default function EmsFDDashboard({ activeDeputy, calls, activeDeputies }:

export const getServerSideProps: GetServerSideProps<Props> = async ({ req, locale }) => {
const user = await getSessionUser(req);
const [values, calls, activeDeputies, activeDeputy] = await requestAll(req, [
const [values, calls, activeDeputies, activeDeputy, activeOfficers] = await requestAll(req, [
["/admin/values/codes_10", []],
["/911-calls", { calls: [], totalCount: 0 }],
["/ems-fd/active-deputies", []],
["/ems-fd/active-deputy", null],
["/leo/active-officers", []],
]);

return {
props: {
session: user,
activeDeputy,
activeDeputies,
activeOfficers,
calls,
values,
messages: {
Expand Down

0 comments on commit 6dcf584

Please sign in to comment.