Skip to content

Commit

Permalink
Add logic to conditionally render accordion checkmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
samau3 committed Sep 18, 2024
1 parent a68d6a4 commit 77eab95
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions client/src/pages/patients/PatientRegistration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ export default function PatientRegistration() {
const [openedSection, setOpenedSection] = useState('patientData');
const [opened, { open, close }] = useDisclosure(false);

const [showCheck, setShowCheck] = useState({
patientData: false,
contactData: false,
medicalData: false,
healthcareChoices: false,
codeStatus: false,
});


const [visitedSections, setVisitedSections] = useState({
patientData: true,
contactData: false,
Expand Down Expand Up @@ -343,6 +352,10 @@ export default function PatientRegistration() {
showSuccessNotification(
'Patient basic information has been successfully registered.',
);
setVisitedSections((prevVisitedSections) => ({
...prevVisitedSections,
patientData: true,
}));
return;
}

Expand Down Expand Up @@ -403,15 +416,23 @@ export default function PatientRegistration() {
* @param {string} value
*/
async function handleAccordionChange(value) {
value === null
? navigate('', { replace: true })
: navigate(`#${value}`, { replace: true });
if (value === null) {
navigate('', { replace: true });
return;
} else {
navigate(`#${value}`, { replace: true });
}

setVisitedSections((prevVisitedSections) => ({
...prevVisitedSections,
[value]: true,
}));

setShowCheck((prevShowCheck) => ({
...prevShowCheck,
[openedSection]: true,
}));

if (!openedSection) {
setOpenedSection(value);
setActive(TABS.indexOf(value));
Expand Down Expand Up @@ -479,6 +500,7 @@ export default function PatientRegistration() {
initialHospitalData={initialHospitalData}
initialPhysicianData={initialPhysicianData}
openedSection={openedSection}
showCheck={showCheck}
handleAccordionChange={handleAccordionChange}
/>
<Flex justify="center" mt="md">
Expand Down

0 comments on commit 77eab95

Please sign in to comment.