From 5e17dcb3bd71d67d9aeda01012743ab719ddf502 Mon Sep 17 00:00:00 2001 From: Tinashe <70011086+tinashechiraya@users.noreply.github.com> Date: Tue, 16 Apr 2024 17:01:31 +0200 Subject: [PATCH 1/2] patch: fix grammar --- .../minisass_frontend/src/components/ScoreForm/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_project/minisass_frontend/src/components/ScoreForm/index.tsx b/django_project/minisass_frontend/src/components/ScoreForm/index.tsx index a9543e44..14c5b270 100644 --- a/django_project/minisass_frontend/src/components/ScoreForm/index.tsx +++ b/django_project/minisass_frontend/src/components/ScoreForm/index.tsx @@ -433,7 +433,7 @@ const ScoreForm: React.FC = ({ 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?" />
Date: Tue, 16 Apr 2024 18:08:44 +0200 Subject: [PATCH 2/2] patch: retry fetching groups after 5 seconds --- .../src/components/ScoreForm/index.tsx | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/django_project/minisass_frontend/src/components/ScoreForm/index.tsx b/django_project/minisass_frontend/src/components/ScoreForm/index.tsx index 14c5b270..716f88f2 100644 --- a/django_project/minisass_frontend/src/components/ScoreForm/index.tsx +++ b/django_project/minisass_frontend/src/components/ScoreForm/index.tsx @@ -52,21 +52,27 @@ const ScoreForm: React.FC = ({ 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: '', @@ -90,7 +96,7 @@ const ScoreForm: React.FC = ({ 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 { @@ -406,7 +412,7 @@ const ScoreForm: React.FC = ({ onCancel, additionalData, setSide }; const handleSiteCloseConfirm = () => { - handleSave(True) + handleSave(true) };