139 lines
No EOL
4.1 KiB
JavaScript
139 lines
No EOL
4.1 KiB
JavaScript
import React, { useState, useEffect } from 'react';
|
||
|
||
const departmentTypeMap = {
|
||
EMS: 'Medical Services',
|
||
Fire: 'Fire Department',
|
||
Rescue: 'Fire & EMS'
|
||
}
|
||
|
||
const accountDetails = {
|
||
"CallThemes" : {
|
||
"CriticalCallList": [
|
||
"CARDIAC ARREST|DEATH",
|
||
],
|
||
"HighCallList": [
|
||
"EMS ALS PRIORITY (ALS)",
|
||
"EMS Advanced Life Support life threatening response (ALS)",
|
||
"EMS ALS Intercept Required",
|
||
"EMS ALS Response – Cardiac Related",
|
||
"EMS ALS Response – Respiratory Distress",
|
||
"EMS ALS Response – Stroke Alert",
|
||
"EMS Basic Life Support with Paramedic Assist (BLS)",
|
||
"EMS ALS Tiered Response with Fire",
|
||
"EMS Response – Behavioral Emergency (ALS)",
|
||
"EMS Response – Obstetric Emergency (ALS)",
|
||
"EMS ALS Response – Overdose / Poisoning",
|
||
"EMS ALS Priority Interfacility Transfer",
|
||
"EMS Response – Unresponsive / Unconscious Patient (ALS)"
|
||
],
|
||
"MediumCallList": [
|
||
"ALS-STANDARD",
|
||
"BLS-PRIORITY",
|
||
"EMS BLS Priority Response",
|
||
"EMS BLS Response – Fall Injury"
|
||
],
|
||
"LowCallList": [
|
||
"EMS Standard Basic Life Support Response (BLS)",
|
||
"EMS BLS Non-Emergency Transport",
|
||
"EMS BLS Standby – Event Coverage",
|
||
"EMS Public Assist – Lift Only (BLS)",
|
||
"EMS BLS Scheduled Interfacility Transport"
|
||
]
|
||
},
|
||
"InitList": [
|
||
{
|
||
deptId: 0,
|
||
dept: 'Darien EMS',
|
||
addDepts: [
|
||
'Darien EMS Supv'
|
||
],
|
||
deptAbv: 'DEMS',
|
||
rank: 'Assistant Director',
|
||
rankAbv: 'Asst. Director',
|
||
type: 'EMS',
|
||
primary: true,
|
||
selected: true,
|
||
supervisor: true,
|
||
admin: true,
|
||
hasVolunteer: true,
|
||
},
|
||
{
|
||
deptId: 1,
|
||
dept: 'Noroton Fire Department',
|
||
deptAbv: 'NFD',
|
||
rank: 'Lieutenant',
|
||
rankAbv: 'Lt.',
|
||
type: 'Fire',
|
||
primary: false,
|
||
selected: false,
|
||
supervisor: true,
|
||
admin: true,
|
||
hasVolunteer: true,
|
||
},
|
||
{
|
||
deptId: 2,
|
||
dept: 'Stamford Fire Department',
|
||
deptAbv: 'SFD',
|
||
rank: 'Paramedic',
|
||
rankAbv: 'EMT-P',
|
||
type: 'Rescue',
|
||
primary: false,
|
||
selected: false,
|
||
supervisor: false,
|
||
admin: true,
|
||
hasVolunteer: false,
|
||
},
|
||
]
|
||
}
|
||
|
||
export const useDepartments = () => {
|
||
const { InitList } = accountDetails;
|
||
const [deptList, setDeptList] = useState(InitList);
|
||
const [selectedDepartment, setSelectedDepartment] = useState(deptList?.find((dept) => {
|
||
return dept?.primary;
|
||
}));
|
||
|
||
const updateSelectedDepartment = (currentSelectedId, newSelectedId) => {
|
||
if (currentSelectedId !== newSelectedId) {
|
||
setDeptList(deptList?.map((item) => {
|
||
if (item?.selected) {
|
||
item.selected = false;
|
||
}
|
||
if (item?.deptId === newSelectedId) {
|
||
item.selected = true;
|
||
}
|
||
return item;
|
||
}))
|
||
}
|
||
};
|
||
|
||
const selectedDepartmentColorPicker = (deptartmentType) => {
|
||
if (deptartmentType === 'Fire') {
|
||
return '#FF0000';
|
||
} else if (deptartmentType === 'EMS') {
|
||
return '#FF8C00';
|
||
} else if (deptartmentType === 'Rescue') {
|
||
return '#0000CD';
|
||
}
|
||
return 'grey';
|
||
};
|
||
|
||
useEffect(() => {
|
||
if (deptList) {
|
||
setSelectedDepartment(deptList?.find((dept) => {
|
||
return dept?.selected;
|
||
}));
|
||
}
|
||
}, [deptList]);
|
||
|
||
return {
|
||
departmentTypeMap,
|
||
accountDetails,
|
||
deptList,
|
||
setDeptList,
|
||
selectedDepartment,
|
||
setSelectedDepartment,
|
||
updateSelectedDepartment,
|
||
selectedDepartmentColorPicker
|
||
}
|
||
} |