From 4d21fbebf8bdfac915c93880c77ae1ce359a98f5 Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Tue, 12 Aug 2025 12:19:05 -0400 Subject: [PATCH] Fix call Statements --- hooks/useCallFeed/useCallFeed.jsx | 33 ++++++++++++++----------- hooks/useDepartments/useDepartments.jsx | 10 ++++---- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/hooks/useCallFeed/useCallFeed.jsx b/hooks/useCallFeed/useCallFeed.jsx index 1560344..3ac5e48 100644 --- a/hooks/useCallFeed/useCallFeed.jsx +++ b/hooks/useCallFeed/useCallFeed.jsx @@ -86,17 +86,22 @@ const formatCallDateTime = (callValue) => { const getIncidents = async (departments, incidentStatus) => { let response; try { - response = await fetch(`${process.env.EXPO_PUBLIC_DATABASE_URL}/getRecentCalls/${5}`, { - method: "GET", + response = await fetch(`${process.env.EXPO_PUBLIC_DATABASE_URL}/getCallsParams`, { + method: "POST", headers: { - apiKey: process.env.EXPO_PUBLIC_DATABASE_API_KEY + apiKey: process.env.EXPO_PUBLIC_DATABASE_API_KEY, + "Content-Type": 'application/json' }, - // body: JSON.stringify({ - // callCount: 25, - // departments, - // status: incidentStatus, - // }), + body: JSON.stringify({ + numCalls: 25, + departments, + status: incidentStatus + }), }); + console.log('response: ', response); + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } } catch (e) { console.error("Failed to fetch initial calls:", e); } @@ -115,7 +120,7 @@ export const useCallFeed = () => { useEffect(() => { async function fetchData() { - const incidents = await getIncidents(InitList?.map((dept) => { return dept?.id }), selectedStatus?.id); + const incidents = await getIncidents(InitList?.map((dept) => { return dept?.deptId }), selectedStatus?.id); setAllCalls(incidents); setInit(false); } @@ -133,7 +138,7 @@ export const useCallFeed = () => { useEffect(() => { async function fetchData() { - const incidents = await getIncidents(InitList?.map((dept) => { return dept?.id }), selectedStatus?.id); + const incidents = await getIncidents(InitList?.map((dept) => { return dept?.deptId }), selectedStatus?.id); setAllCalls(incidents); } if (!init) { @@ -144,13 +149,13 @@ export const useCallFeed = () => { const callColorSelector = (callAcuity, cardiacArrestCall, status) => { if (status?.toLowerCase() === "closed") { return "#0000CD"; - } else if (CriticalCallList.includes(cardiacArrestCall)) { + } else if (CriticalCallList.some(critical => cardiacArrestCall.includes(critical))) { return "#8B0000"; - } else if (HighCallList.includes(callAcuity)) { + } else if (HighCallList.some(high => callAcuity.includes(high))) { return "#FF0000"; - } else if (MediumCallList.includes(callAcuity)) { + } else if (MediumCallList.some(medium => callAcuity.includes(medium))) { return "#FF8C00"; - } else if (LowCallList.includes(callAcuity)) { + } else if (LowCallList.some(low => callAcuity.includes(low))) { return "#228B22"; } return "grey"; diff --git a/hooks/useDepartments/useDepartments.jsx b/hooks/useDepartments/useDepartments.jsx index 877bff9..a8e5415 100644 --- a/hooks/useDepartments/useDepartments.jsx +++ b/hooks/useDepartments/useDepartments.jsx @@ -9,7 +9,7 @@ const departmentTypeMap = { const accountDetails = { "CallThemes" : { "CriticalCallList": [ - "CARDIAC ARREST|DEATH", + "CARDIAC ARREST" ], "HighCallList": [ "EMS ALS PRIORITY (ALS)", @@ -42,7 +42,7 @@ const accountDetails = { }, "InitList": [ { - deptId: 0, + deptId: 1, dept: 'Darien EMS', addDepts: [ 'Darien EMS Supv' @@ -58,7 +58,7 @@ const accountDetails = { hasVolunteer: true, }, { - deptId: 1, + deptId: 2, dept: 'Noroton Fire Department', deptAbv: 'NFD', rank: 'Lieutenant', @@ -71,8 +71,8 @@ const accountDetails = { hasVolunteer: true, }, { - deptId: 2, - dept: 'Stamford Fire Department', + deptId: 3, + dept: 'Stamford Fire Rescue', deptAbv: 'SFD', rank: 'Paramedic', rankAbv: 'EMT-P',