Skip to content

Commit

Permalink
Merge pull request #983 from kartoza/save-observation-to-existing-site
Browse files Browse the repository at this point in the history
patch: fix grammar
  • Loading branch information
tinashechiraya authored Apr 16, 2024
2 parents 82f11c8 + cb940b1 commit c13adbb
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions django_project/minisass_frontend/src/components/ScoreForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,27 @@ const ScoreForm: React.FC<ScoreFormProps> = ({ onCancel, additionalData, setSide

useEffect(() => {
const fetchScoreGroups = async () => {
try {
setIsSavingData(true)
const response = await axios.get(`${globalVariables.baseUrl}/group-scores/`);
if(response.status == 200){
setScoreGroups(response.data);
setButtonStates(response.data.map(score => ({ id: score.id, showManageImages: false })))
setIsSavingData(false)
} else; // TODO trigger a retry in about 3 seconds
} catch (error) {
console.error('Error fetching score groups:', error);
}
try {
setIsSavingData(true);
const response = await axios.get(`${globalVariables.baseUrl}/group-scores/`);
if (response.status === 200) {
setScoreGroups(response.data);
setButtonStates(response.data.map(score => ({ id: score.id, showManageImages: false })));
setIsSavingData(false);
} else {
// Retry after 5 seconds
setTimeout(fetchScoreGroups, 5000);
}
} catch (error) {
console.error('Error fetching score groups:', error);
// Retry after 5 seconds
setTimeout(fetchScoreGroups, 5000);
}
};

fetchScoreGroups();
}, []);
}, []);


const [manageImagesModalData, setManageImagesModalData] = useState({
groups: '',
Expand All @@ -90,7 +96,7 @@ const ScoreForm: React.FC<ScoreFormProps> = ({ onCancel, additionalData, setSide
const [siteId, setSiteId] = useState(0);

// Function to log the state of checkboxes
const handleSave = async (saveToExistingSite) => {
const handleSave = async (saveToExistingSite = false) => {
setIsSavingData(true)
try {

Expand Down Expand Up @@ -406,7 +412,7 @@ const ScoreForm: React.FC<ScoreFormProps> = ({ onCancel, additionalData, setSide
};

const handleSiteCloseConfirm = () => {
handleSave(True)
handleSave(true)
};


Expand All @@ -433,7 +439,7 @@ const ScoreForm: React.FC<ScoreFormProps> = ({ onCancel, additionalData, setSide
onClose={handleSiteDialogCancel}
onConfirm={handleSiteCloseConfirm}
title="Cannot Save Observation"
message="You chose create new site but the sitename you provided already exists, should the observation be saved to this site instead?"
message="You chose create new site but the Site name you provided already exists, should the observation be saved to this site instead?"
/>

<div className="flex flex-col font-raleway items-center justify-start mx-auto p-0.5 w-full"
Expand Down

0 comments on commit c13adbb

Please sign in to comment.