From 067c3e9df1673b0d433c416749f8e2b2c8f1b99c Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Mon, 25 Aug 2025 10:35:59 -0400 Subject: [PATCH] linter --- app/incidents.jsx | 312 ++++++++++++++++++++++++++++------------------ 1 file changed, 191 insertions(+), 121 deletions(-) diff --git a/app/incidents.jsx b/app/incidents.jsx index a5c0308..8041d84 100644 --- a/app/incidents.jsx +++ b/app/incidents.jsx @@ -1,22 +1,30 @@ -import React, { useState, useRef, useEffect } from 'react'; -import styled from 'styled-components'; -import { useCallFeed } from '@/hooks'; -import { router } from 'expo-router'; -import { Platform, Linking, View, ScrollView, Text, TouchableOpacity } from 'react-native'; -import { StatusBar } from 'expo-status-bar'; -import { SafeAreaView } from 'react-native-safe-area-context'; +import React, { useState, useRef, useEffect } from "react"; +import styled from "styled-components"; +import { useCallFeed } from "@/hooks"; +import { router } from "expo-router"; import { - PageHeader, - PageFooter, -} from '@/components/generalHelpers.jsx'; -import { Ionicons } from '@expo/vector-icons'; + Platform, + Linking, + View, + ScrollView, + Text, + TouchableOpacity, +} from "react-native"; +import { StatusBar } from "expo-status-bar"; +import { SafeAreaView } from "react-native-safe-area-context"; +import { PageHeader, PageFooter } from "@/components/generalHelpers.jsx"; +import { Ionicons } from "@expo/vector-icons"; import { AccidentAndEmergency } from "healthicons-react-native/dist/outline"; -import ActionSheet from 'react-native-actions-sheet'; +import ActionSheet from "react-native-actions-sheet"; const DepartmentActionSheet = styled(ActionSheet)``; function toBase64Unicode(str) { - return btoa(new TextEncoder().encode(str).reduce((data, byte) => data + String.fromCharCode(byte), '')); + return btoa( + new TextEncoder() + .encode(str) + .reduce((data, byte) => data + String.fromCharCode(byte), "") + ); } export default function Incidents() { @@ -29,16 +37,26 @@ export default function Incidents() { callDetails, callColorSelector, formatCallTimePast, - formatCallDateTime + formatCallDateTime, } = callFeed; - const sortedAndFilteredCalls = callDetails.sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp)) - .filter((item, index, self) => { - return index === self.findIndex(i => { - return `${i?.incident?.incID}${i?.response?.serviceName}` === `${item?.incident?.incID}${item?.response?.serviceName}` - }); - })?.map(item => { return {...item, timestamp: item?.incident?.incDate} }) - || []; + const sortedAndFilteredCalls = + callDetails + .sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp)) + .filter((item, index, self) => { + return ( + index === + self.findIndex((i) => { + return ( + `${i?.incident?.incID}${i?.response?.serviceName}` === + `${item?.incident?.incID}${item?.response?.serviceName}` + ); + }) + ); + }) + ?.map((item) => { + return { ...item, timestamp: item?.incident?.incDate }; + }) || []; const { departmentTypeMap, @@ -53,38 +71,44 @@ export default function Incidents() { return ( - { - actionSheetRef.current?.show(); - }} - > - + { + actionSheetRef.current?.show(); }} > - {selectedDepartment?.deptAbv} - - } + + {selectedDepartment?.deptAbv} + + + + } /> - + {sortedAndFilteredCalls?.length ? ( sortedAndFilteredCalls?.map((callItem, index) => { const { incident, address, response, timestamp } = callItem; @@ -103,28 +127,27 @@ export default function Incidents() { state, locationName, } = address; - const { - serviceName - } = response; - const SelectedIcon = callIconMap[incNature] || AccidentAndEmergency; + const { serviceName } = response; + const SelectedIcon = + callIconMap[incNature] || AccidentAndEmergency; return ( { router.push({ - pathname: '/call', + pathname: "/call", params: { - callDetails: toBase64Unicode(JSON.stringify(callItem)) - } - }) + callDetails: toBase64Unicode(JSON.stringify(callItem)), + }, + }); }} > - - + - {formatCallDateTime(incDate)} - - {formatCallTimePast(incDate)} - {status === 'CLOSED' ? ( + + {formatCallDateTime(incDate)} + + + + {formatCallTimePast(incDate)} + + {status === "CLOSED" ? ( ) : null} - + - + {locationName ? ( {`${locationName}`} ) : ( - + - {`${streetAddress?.split(',')[0]}`} + {`${streetAddress?.split(",")[0]}`} {addressApartment ? ( {` - ${addressApartment}`} ) : null} {` ${town}, ${state}`} @@ -218,24 +264,29 @@ export default function Incidents() { )} {`${incNature}`} - + {`${incNatureCodeDesc}`} @@ -248,7 +299,13 @@ export default function Incidents() { - + {`Incident #: ${serviceNumber}`} @@ -268,8 +325,9 @@ export default function Incidents() { - ) - })) : ( + ); + }) + ) : ( There are no Calls )} @@ -277,11 +335,11 @@ export default function Incidents() { @@ -291,10 +349,10 @@ export default function Incidents() { containerStyle={{ height: "50%", width: "100%", - backgroundColor: '#ECEDEE', + backgroundColor: "#ECEDEE", }} > - + {deptList?.map((item) => { return ( @@ -302,44 +360,56 @@ export default function Incidents() { style={{ borderRadius: 6, elevation: 3, - backgroundColor: item?.selected ? 'grey' : '#fff', + backgroundColor: item?.selected ? "grey" : "#fff", shadowOffset: { width: 1, height: 1 }, - shadowColor: '#333', + shadowColor: "#333", shadowOpacity: 0.3, shadowRadius: 2, marginHorizontal: 20, marginVertical: 6, - padding: 10 + padding: 10, }} onPress={() => { actionSheetRef.current?.hide(); return updateSelectedDepartment( selectedDepartment?.deptId, item?.deptId - ) + ); }} > - + {item?.dept} - {item?.primary ? : null} + {item?.primary ? ( + + ) : null} - {`${item?.deptAbv} - ${departmentTypeMap[item?.type]}`} + {`${item?.deptAbv} - ${ + departmentTypeMap[item?.type] + }`} ); @@ -347,5 +417,5 @@ export default function Incidents() { - ) -} \ No newline at end of file + ); +}