Skip to content

Commit

Permalink
Save row turns green only when save is complete (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
reddyrose authored Sep 14, 2023
1 parent 0c92adf commit d69a6cc
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/components/ECGList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ export default function ECGList() {
let n = 5;
while (ecg.component[n].valueString !== undefined){
const new_symptom = ecg.component[n].code.coding[0].display
console.log(`${new_symptom} exists.`);

symptom = `${symptom}, ${new_symptom}`
n += 1;
}
Expand Down Expand Up @@ -100,13 +98,6 @@ export default function ECGList() {
const updatedRowData = [...diagnoses];
updatedRowData[index] = selectedItem;
setDiagnoses(updatedRowData);

if (typeof selectedItem === 'string') {
console.log('The field is a string.');
} else {
console.log('The field is not a string.');
}

console.log('Selected Item:', selectedItem);
}
function handleQualityDropdownChange(index, event) {
Expand Down Expand Up @@ -153,17 +144,22 @@ export default function ECGList() {

console.log('Fields added to the document successfully');
}
handleSaveButtonClick(ECG_ID); // change Row to green only if save is complete
} catch (error) {
console.error('Error adding fields to the document:', error);
console.error('Error adding fields to the document: ', error);
}
};

const handleSave = (index, ECG_ID) => {
console.log(`Row ${index + 1} saved: ${names[index]}`);
console.log(`Row ${index + 1} saved: ${diagnoses[index]}`);
console.log(`Row ${index + 1} saved: ${qualities[index]}`);
diagnosisToFirebase(names[index], diagnoses[index], qualities[index], ECG_ID)
};
try {
diagnosisToFirebase(names[index], diagnoses[index], qualities[index], ECG_ID)
} catch (error) {
}
}
;

useEffect(() => {
const getEcgs = async () => {
Expand Down Expand Up @@ -305,7 +301,6 @@ export default function ECGList() {
sx={{ width: 100, margin: 2 }} style={{ backgroundColor: '#10AD92' }}
onClick={(event) => {
handleSave(index, ecg.id);
handleSaveButtonClick(ecg.id);
}}>
Save
</Button>
Expand Down

0 comments on commit d69a6cc

Please sign in to comment.