2024-10-05 23:10:41 +00:00
|
|
|
import React, { useState, useRef, useEffect } from 'react';
|
|
|
|
|
import styled from 'styled-components';
|
2025-04-21 15:41:08 +00:00
|
|
|
import { useCallFeed } from '@/hooks';
|
2025-04-19 06:36:25 +00:00
|
|
|
import { router } from 'expo-router';
|
2024-10-05 23:10:41 +00:00
|
|
|
import { Platform, Linking, View, ScrollView, Text, TouchableOpacity } from 'react-native';
|
2025-04-19 06:36:25 +00:00
|
|
|
import { StatusBar } from 'expo-status-bar';
|
|
|
|
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
2024-10-05 23:10:41 +00:00
|
|
|
import {
|
2025-08-10 14:14:56 +00:00
|
|
|
PageHeader,
|
|
|
|
|
PageFooter,
|
2025-08-10 07:11:09 +00:00
|
|
|
} from '@/components/generalHelpers.jsx';
|
2024-10-05 23:10:41 +00:00
|
|
|
import { Ionicons } from '@expo/vector-icons';
|
2025-04-19 06:36:25 +00:00
|
|
|
import { AccidentAndEmergency } from "healthicons-react-native/dist/outline";
|
2024-10-05 23:10:41 +00:00
|
|
|
import ActionSheet from 'react-native-actions-sheet';
|
|
|
|
|
|
|
|
|
|
const DepartmentActionSheet = styled(ActionSheet)``;
|
|
|
|
|
|
|
|
|
|
export default function Incidents() {
|
2025-04-21 15:41:08 +00:00
|
|
|
const actionSheetRef = useRef(null);
|
|
|
|
|
const callFeed = useCallFeed();
|
2024-10-05 23:10:41 +00:00
|
|
|
|
2025-04-21 15:41:08 +00:00
|
|
|
const {
|
2025-08-10 14:14:56 +00:00
|
|
|
departments,
|
|
|
|
|
callIconMap,
|
|
|
|
|
callDetails,
|
|
|
|
|
callColorSelector,
|
|
|
|
|
formatCallTimePast,
|
|
|
|
|
formatCallDateTime
|
2025-04-21 15:41:08 +00:00
|
|
|
} = callFeed;
|
2024-10-05 23:10:41 +00:00
|
|
|
|
2025-04-21 15:41:08 +00:00
|
|
|
const sortedAndFilteredCalls = callDetails
|
2025-08-10 14:14:56 +00:00
|
|
|
.sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp))
|
|
|
|
|
.filter((item, index, self) => {
|
|
|
|
|
return index === self.findIndex(i => {
|
|
|
|
|
return `${i?.data?.Incident?.IncID}${i?.data?.Response?.ServiceName}` === `${item?.data?.Incident?.IncID}${item?.data?.Response?.ServiceName}`
|
2025-04-21 15:41:08 +00:00
|
|
|
});
|
2025-08-10 14:14:56 +00:00
|
|
|
});
|
2025-04-19 06:36:25 +00:00
|
|
|
|
2025-04-21 15:41:08 +00:00
|
|
|
const {
|
2025-08-10 14:14:56 +00:00
|
|
|
departmentTypeMap,
|
|
|
|
|
accountDetails,
|
|
|
|
|
deptList,
|
|
|
|
|
setDeptList,
|
|
|
|
|
selectedDepartment,
|
|
|
|
|
setSelectedDepartment,
|
|
|
|
|
updateSelectedDepartment,
|
|
|
|
|
selectedDepartmentColorPicker,
|
2025-04-21 15:41:08 +00:00
|
|
|
} = departments;
|
2024-10-05 23:10:41 +00:00
|
|
|
|
2025-04-21 15:41:08 +00:00
|
|
|
return (
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
<PageHeader>
|
2025-08-10 14:14:56 +00:00
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
flexDirection: 'column',
|
|
|
|
|
height: 80,
|
|
|
|
|
alignItems: 'center',
|
2025-04-21 15:41:08 +00:00
|
|
|
justifyContent: 'flex-end',
|
|
|
|
|
paddingBottom: 7
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
style={{
|
|
|
|
|
borderRadius: 6,
|
|
|
|
|
elevation: 3,
|
|
|
|
|
backgroundColor: '#fff',
|
|
|
|
|
shadowOffset: { width: 0, height: 0 },
|
|
|
|
|
shadowColor: '#333',
|
|
|
|
|
shadowOpacity: .8,
|
|
|
|
|
shadowRadius: 2,
|
|
|
|
|
paddingHorizontal: 10,
|
|
|
|
|
paddingVertical: 2,
|
|
|
|
|
}}
|
|
|
|
|
onPress={() => {
|
|
|
|
|
actionSheetRef.current?.show();
|
|
|
|
|
}}
|
|
|
|
|
>
|
2025-08-10 14:14:56 +00:00
|
|
|
<Text
|
|
|
|
|
style={{
|
|
|
|
|
color: selectedDepartmentColorPicker(selectedDepartment?.type),
|
|
|
|
|
fontWeight: 600,
|
2025-04-21 15:41:08 +00:00
|
|
|
fontSize: 14
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{selectedDepartment?.deptAbv}
|
|
|
|
|
</Text>
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
</View>
|
|
|
|
|
</PageHeader>
|
|
|
|
|
<ScrollView>
|
2025-08-10 14:14:56 +00:00
|
|
|
<StatusBar style="dark" />
|
|
|
|
|
<SafeAreaView />
|
|
|
|
|
<View style={{ flexDirection: 'column', padding: 20 }}>
|
|
|
|
|
{sortedAndFilteredCalls?.length ? (
|
|
|
|
|
sortedAndFilteredCalls?.map((callItem, index) => {
|
2025-04-21 15:41:08 +00:00
|
|
|
const { data: call, timestamp } = callItem;
|
|
|
|
|
const { Incident, Address, Response } = call;
|
|
|
|
|
const {
|
|
|
|
|
ServiceNumber,
|
|
|
|
|
IncDate,
|
|
|
|
|
IncNature,
|
|
|
|
|
IncNatureCode,
|
|
|
|
|
IncNatureCodeDesc,
|
|
|
|
|
Status,
|
|
|
|
|
} = Incident;
|
|
|
|
|
const {
|
|
|
|
|
StreetAddress,
|
|
|
|
|
AddressApartment,
|
|
|
|
|
Town,
|
|
|
|
|
State,
|
|
|
|
|
LocationName,
|
|
|
|
|
} = Address;
|
|
|
|
|
const {
|
|
|
|
|
ServiceName
|
|
|
|
|
} = Response;
|
|
|
|
|
const SelectedIcon = callIconMap[IncNature] || AccidentAndEmergency;
|
|
|
|
|
return (
|
2025-08-10 14:14:56 +00:00
|
|
|
<TouchableOpacity
|
|
|
|
|
key={`callDetails - ${timestamp}`}
|
2025-04-21 15:41:08 +00:00
|
|
|
style={{ padding: 2 }}
|
|
|
|
|
onPress={() => {
|
|
|
|
|
router.push({
|
|
|
|
|
pathname: '/call',
|
|
|
|
|
params: {
|
|
|
|
|
callDetails: btoa(JSON.stringify(call))
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}}
|
2024-10-05 23:10:41 +00:00
|
|
|
>
|
2025-08-10 14:14:56 +00:00
|
|
|
<View
|
2025-04-21 15:41:08 +00:00
|
|
|
style={{
|
|
|
|
|
borderRadius: 12,
|
|
|
|
|
elevation: 3,
|
|
|
|
|
backgroundColor: '#fff',
|
|
|
|
|
shadowOffset: { width: 0, height: 0 },
|
|
|
|
|
shadowColor: callColorSelector(
|
2025-08-10 14:14:56 +00:00
|
|
|
IncNatureCode,
|
2025-04-21 15:41:08 +00:00
|
|
|
IncNature,
|
|
|
|
|
Status
|
|
|
|
|
),
|
|
|
|
|
shadowOpacity: 1,
|
|
|
|
|
shadowRadius: 5,
|
|
|
|
|
padding: 10,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<View style={{ flexDirection: 'column' }}>
|
|
|
|
|
<View key="callDateAndTime"
|
2025-08-10 14:14:56 +00:00
|
|
|
style={{
|
2025-04-21 15:41:08 +00:00
|
|
|
paddingBottom: 6,
|
2025-08-10 14:14:56 +00:00
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'space-between'
|
2024-10-05 23:10:41 +00:00
|
|
|
}}
|
2025-04-21 15:41:08 +00:00
|
|
|
>
|
|
|
|
|
<Text style={{ fontSize: 12 }}>{formatCallDateTime(IncDate)}</Text>
|
|
|
|
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
|
|
|
<Text style={{ fontSize: 12 }}>{formatCallTimePast(IncDate)}</Text>
|
|
|
|
|
{Status === 'CLOSED' ? (
|
|
|
|
|
<Ionicons
|
|
|
|
|
name="lock-closed-outline"
|
|
|
|
|
color='red'
|
|
|
|
|
style={{
|
2025-08-10 14:14:56 +00:00
|
|
|
shadowColor: 'black',
|
2025-04-21 15:41:08 +00:00
|
|
|
shadowOffset: 0,
|
2025-08-10 14:14:56 +00:00
|
|
|
shadowOpacity: 1,
|
2025-04-21 15:41:08 +00:00
|
|
|
shadowRadius: 10
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
) : null}
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
|
2025-08-10 14:14:56 +00:00
|
|
|
<SelectedIcon
|
2025-04-21 15:41:08 +00:00
|
|
|
color={callColorSelector(
|
2025-08-10 14:14:56 +00:00
|
|
|
IncNatureCode,
|
2025-04-21 15:41:08 +00:00
|
|
|
IncNature,
|
|
|
|
|
Status
|
2025-08-10 14:14:56 +00:00
|
|
|
)}
|
|
|
|
|
opacity={0.3}
|
|
|
|
|
width={56}
|
2025-04-21 15:41:08 +00:00
|
|
|
height={56}
|
|
|
|
|
/>
|
|
|
|
|
<View style={{ flexDirection: 'column' }}>
|
|
|
|
|
{LocationName ? (
|
2025-08-10 14:14:56 +00:00
|
|
|
<Text
|
|
|
|
|
style={{
|
|
|
|
|
color: 'black',
|
|
|
|
|
fontWeight: 600,
|
|
|
|
|
fontSize: 16
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{`${LocationName}`}
|
|
|
|
|
</Text>
|
2025-04-21 15:41:08 +00:00
|
|
|
) : (
|
|
|
|
|
<View style={{ flexDirection: 'row' }}>
|
2025-08-10 14:14:56 +00:00
|
|
|
<Text
|
2025-04-21 15:41:08 +00:00
|
|
|
style={[{
|
|
|
|
|
color: 'black',
|
2025-08-10 14:14:56 +00:00
|
|
|
fontSize: 12,
|
2025-04-21 15:41:08 +00:00
|
|
|
fontWeight: 600
|
|
|
|
|
}]}
|
|
|
|
|
>
|
|
|
|
|
{`${StreetAddress}`}
|
|
|
|
|
</Text>
|
|
|
|
|
{AddressApartment ? (
|
2025-08-10 14:14:56 +00:00
|
|
|
<Text
|
2025-04-21 15:41:08 +00:00
|
|
|
style={[{
|
|
|
|
|
color: 'black',
|
2025-08-10 14:14:56 +00:00
|
|
|
fontSize: 12,
|
2025-04-21 15:41:08 +00:00
|
|
|
fontWeight: 600
|
|
|
|
|
}]}
|
|
|
|
|
>
|
|
|
|
|
{` - ${AddressApartment}`}
|
|
|
|
|
</Text>
|
2025-08-10 14:14:56 +00:00
|
|
|
) : null}
|
|
|
|
|
<Text
|
2025-04-21 15:41:08 +00:00
|
|
|
style={[{
|
|
|
|
|
color: 'black',
|
2025-08-10 14:14:56 +00:00
|
|
|
fontSize: 12,
|
2025-04-21 15:41:08 +00:00
|
|
|
fontWeight: 600
|
|
|
|
|
}]}
|
|
|
|
|
>
|
|
|
|
|
{` ${Town}, ${State}`}
|
|
|
|
|
</Text>
|
|
|
|
|
</View>
|
|
|
|
|
)}
|
2025-08-10 14:14:56 +00:00
|
|
|
<Text
|
|
|
|
|
style={{
|
|
|
|
|
color: 'black',
|
|
|
|
|
fontWeight: 600,
|
|
|
|
|
fontSize: 16
|
2024-10-05 23:10:41 +00:00
|
|
|
}}
|
2025-04-21 15:41:08 +00:00
|
|
|
>
|
|
|
|
|
{`${IncNature}`}
|
|
|
|
|
</Text>
|
|
|
|
|
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
2025-08-10 14:14:56 +00:00
|
|
|
<Text
|
|
|
|
|
style={{
|
|
|
|
|
color: 'black',
|
|
|
|
|
fontSize: 12,
|
2025-04-21 15:41:08 +00:00
|
|
|
textShadowColor: callColorSelector(
|
2025-08-10 14:14:56 +00:00
|
|
|
IncNatureCode,
|
2025-04-21 15:41:08 +00:00
|
|
|
IncNature,
|
|
|
|
|
Status
|
2025-08-10 14:14:56 +00:00
|
|
|
),
|
|
|
|
|
textShadowRadius: 1
|
2025-04-21 15:41:08 +00:00
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{`${IncNatureCodeDesc}`}
|
|
|
|
|
</Text>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
<View style={{ padding: 0 }}>
|
2025-08-10 14:14:56 +00:00
|
|
|
<View>
|
|
|
|
|
<Ionicons name="chevron-forward-outline" />
|
|
|
|
|
</View>
|
2025-04-21 15:41:08 +00:00
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
|
|
|
<Text
|
2025-08-10 14:14:56 +00:00
|
|
|
style={{
|
2025-04-21 15:41:08 +00:00
|
|
|
fontSize: 12,
|
|
|
|
|
}}
|
2024-10-05 23:10:41 +00:00
|
|
|
>
|
2025-04-21 15:41:08 +00:00
|
|
|
Service: {ServiceName}
|
2024-10-05 23:10:41 +00:00
|
|
|
</Text>
|
2025-04-21 15:41:08 +00:00
|
|
|
<Text
|
|
|
|
|
style={{
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
textAlign: 'right'
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{`Incident #: ${ServiceNumber}`}
|
|
|
|
|
</Text>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
)
|
|
|
|
|
})) : (
|
2025-08-10 14:14:56 +00:00
|
|
|
<Text>There are no Calls</Text>
|
|
|
|
|
)}
|
2025-04-21 15:41:08 +00:00
|
|
|
</View>
|
2025-08-10 14:14:56 +00:00
|
|
|
</ScrollView>
|
|
|
|
|
<PageFooter>
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
flexDirection: 'column',
|
|
|
|
|
height: 100,
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
justifyContent: 'flex-start',
|
|
|
|
|
paddingTop: 7
|
|
|
|
|
}}
|
2025-04-21 15:41:08 +00:00
|
|
|
/>
|
2025-08-10 14:14:56 +00:00
|
|
|
</PageFooter>
|
|
|
|
|
<DepartmentActionSheet
|
2025-04-21 15:41:08 +00:00
|
|
|
ref={actionSheetRef}
|
|
|
|
|
gestureEnabled
|
|
|
|
|
containerStyle={{
|
2025-08-10 14:14:56 +00:00
|
|
|
height: "50%",
|
|
|
|
|
width: "100%",
|
|
|
|
|
backgroundColor: '#ECEDEE',
|
2025-04-21 15:41:08 +00:00
|
|
|
}}
|
2025-08-10 14:14:56 +00:00
|
|
|
>
|
2025-04-21 15:41:08 +00:00
|
|
|
<View style={{ flexDirection: 'column', padding: 20 }}>
|
2025-08-10 14:14:56 +00:00
|
|
|
{deptList?.map((item) => {
|
|
|
|
|
return (
|
|
|
|
|
<View style={{ padding: 2 }} key={item?.deptId}>
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
style={{
|
|
|
|
|
borderRadius: 6,
|
|
|
|
|
elevation: 3,
|
|
|
|
|
backgroundColor: item?.selected ? 'grey' : '#fff',
|
|
|
|
|
shadowOffset: { width: 1, height: 1 },
|
|
|
|
|
shadowColor: '#333',
|
|
|
|
|
shadowOpacity: 0.3,
|
|
|
|
|
shadowRadius: 2,
|
|
|
|
|
marginHorizontal: 20,
|
|
|
|
|
marginVertical: 6,
|
|
|
|
|
padding: 10
|
|
|
|
|
}}
|
|
|
|
|
onPress={() => {
|
|
|
|
|
actionSheetRef.current?.hide();
|
|
|
|
|
return updateSelectedDepartment(
|
|
|
|
|
selectedDepartment?.deptId,
|
|
|
|
|
item?.deptId
|
|
|
|
|
)
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
|
|
|
<Text
|
|
|
|
|
style={{
|
|
|
|
|
color: selectedDepartmentColorPicker(
|
|
|
|
|
item?.type
|
|
|
|
|
),
|
|
|
|
|
fontWeight: 600,
|
|
|
|
|
fontSize: 16
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{item?.dept}
|
|
|
|
|
</Text>
|
|
|
|
|
{item?.primary ? <Ionicons name="star" size={16} color="yellow" style={{
|
|
|
|
|
paddingLeft: 20,
|
|
|
|
|
shadowColor: '#333',
|
|
|
|
|
shadowOffset: 1,
|
|
|
|
|
shadowOpacity: 1,
|
|
|
|
|
shadowRadius: 6
|
|
|
|
|
}} /> : null}
|
|
|
|
|
</View>
|
|
|
|
|
<Text>{`${item?.deptAbv} - ${departmentTypeMap[item?.type]}`}</Text>
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
</View>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2025-04-21 15:41:08 +00:00
|
|
|
</View>
|
2025-08-10 14:14:56 +00:00
|
|
|
</DepartmentActionSheet>
|
2025-04-21 15:41:08 +00:00
|
|
|
</React.Fragment>
|
|
|
|
|
)
|
2024-10-05 23:10:41 +00:00
|
|
|
}
|