json download and localstorage
This commit is contained in:
parent
84a55d48c8
commit
2fd461222a
@ -178,6 +178,8 @@ export default function PatientDetails(){
|
|||||||
setIsChecked(event.target.checked);
|
setIsChecked(event.target.checked);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//@ts-ignore
|
||||||
|
const patientData = localStorage.getItem('patientData') ? JSON.parse(localStorage.getItem('patientData')) : [];
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<>
|
<>
|
||||||
@ -200,7 +202,7 @@ export default function PatientDetails(){
|
|||||||
</AccordionSummary>
|
</AccordionSummary>
|
||||||
|
|
||||||
<AccordionDetails>
|
<AccordionDetails>
|
||||||
<PersonalSection personalData={personalData} />
|
<PersonalSection personalData={patientData?.section1} />
|
||||||
</AccordionDetails>
|
</AccordionDetails>
|
||||||
|
|
||||||
</Accordion>
|
</Accordion>
|
||||||
@ -211,7 +213,7 @@ export default function PatientDetails(){
|
|||||||
</AccordionSummary>
|
</AccordionSummary>
|
||||||
|
|
||||||
<AccordionDetails>
|
<AccordionDetails>
|
||||||
<FamilyFormSection familyDetails={familyData}/>
|
<FamilyFormSection familyDetails={patientData?.section2}/>
|
||||||
</AccordionDetails>
|
</AccordionDetails>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|
||||||
|
|||||||
@ -339,8 +339,21 @@ export default function PatientForm(){
|
|||||||
// Update the state with the new array
|
// Update the state with the new array
|
||||||
setAllPatientData(updatedAllPatientData);
|
setAllPatientData(updatedAllPatientData);
|
||||||
|
|
||||||
|
localStorage.setItem('patientData', JSON.stringify(newPatientData));
|
||||||
|
|
||||||
console.log("UpdatedallPatientData:", updatedAllPatientData);
|
console.log("UpdatedallPatientData:", updatedAllPatientData);
|
||||||
};
|
TextFile();
|
||||||
|
};
|
||||||
|
|
||||||
|
const TextFile = () => {
|
||||||
|
const element = document.createElement("a");
|
||||||
|
//@ts-ignore
|
||||||
|
const textFile = new Blob([localStorage.getItem('patientData')], {type: 'text/json'});
|
||||||
|
element.href = URL.createObjectURL(textFile);
|
||||||
|
element.download = "patientData.json";
|
||||||
|
document.body.appendChild(element);
|
||||||
|
element.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const handleExpandChange =
|
const handleExpandChange =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user