json download and localstorage
This commit is contained in:
parent
84a55d48c8
commit
2fd461222a
@ -177,7 +177,9 @@ export default function PatientDetails(){
|
||||
const handleCheckboxChange = (event:any) => {
|
||||
setIsChecked(event.target.checked);
|
||||
};
|
||||
|
||||
|
||||
//@ts-ignore
|
||||
const patientData = localStorage.getItem('patientData') ? JSON.parse(localStorage.getItem('patientData')) : [];
|
||||
|
||||
return(
|
||||
<>
|
||||
@ -200,7 +202,7 @@ export default function PatientDetails(){
|
||||
</AccordionSummary>
|
||||
|
||||
<AccordionDetails>
|
||||
<PersonalSection personalData={personalData} />
|
||||
<PersonalSection personalData={patientData?.section1} />
|
||||
</AccordionDetails>
|
||||
|
||||
</Accordion>
|
||||
@ -211,7 +213,7 @@ export default function PatientDetails(){
|
||||
</AccordionSummary>
|
||||
|
||||
<AccordionDetails>
|
||||
<FamilyFormSection familyDetails={familyData}/>
|
||||
<FamilyFormSection familyDetails={patientData?.section2}/>
|
||||
</AccordionDetails>
|
||||
</Accordion>
|
||||
|
||||
|
||||
@ -338,9 +338,22 @@ export default function PatientForm(){
|
||||
|
||||
// Update the state with the new array
|
||||
setAllPatientData(updatedAllPatientData);
|
||||
|
||||
localStorage.setItem('patientData', JSON.stringify(newPatientData));
|
||||
|
||||
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 =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user