diff --git a/client/src/Context.js b/client/src/Context.js
index 14adc654..f35f92b0 100644
--- a/client/src/Context.js
+++ b/client/src/Context.js
@@ -10,6 +10,7 @@ function ContextProvider({ children }) {
const [organization, setOrganization] = useState();
const [hospital, setHospital] = useState();
const [hospitalUser, setHospitalUser] = useState();
+ const [ringdownSection, setRingdownSection] = useState({});
const value = {
user,
@@ -24,6 +25,8 @@ function ContextProvider({ children }) {
setHospital,
hospitalUser,
setHospitalUser,
+ ringdownSection,
+ setRingdownSection,
};
return {children};
}
diff --git a/client/src/ER/RingdownSection.js b/client/src/ER/RingdownSection.js
index 52ebaae8..188470e1 100644
--- a/client/src/ER/RingdownSection.js
+++ b/client/src/ER/RingdownSection.js
@@ -1,21 +1,31 @@
-import React, { useState } from 'react';
+import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import Ringdown from '../Models/Ringdown';
import RingdownCard from '../Components/RingdownCard';
+import Context from '../Context';
import './RingdownSection.scss';
function RingdownSection({ title, ringdowns, onStatusChange }) {
- const [isExpanded, setExpanded] = useState(true);
+ const { ringdownSection, setRingdownSection } = useContext(Context);
+
+ const isExpanded = !!ringdownSection[title];
+
+ const handleExpand = () => {
+ setRingdownSection({
+ ...ringdownSection,
+ [title]: !isExpanded,
+ });
+ };
return (
setExpanded(!isExpanded)}
+ onClick={handleExpand}
onKeyDown={(event) => {
- if (event.key === 'Enter') setExpanded(!isExpanded);
+ if (event.key === 'Enter') handleExpand();
}}
role="button"
tabIndex={0}