From b7933867030c1664634743dde2ff906aaf4e8202 Mon Sep 17 00:00:00 2001 From: john681611 Date: Tue, 17 Oct 2023 20:31:42 +0100 Subject: [PATCH] Fix GA loading disappearing --- .../src/pages/GapAnalysis/GapAnalysis.tsx | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx b/application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx index 7b0ea71c4..e69d24726 100644 --- a/application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx +++ b/application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx @@ -127,7 +127,8 @@ export const GapAnalysis = () => { ); const [gapAnalysis, setGapAnalysis] = useState>(); const [activeIndex, SetActiveIndex] = useState(); - const [loading, setLoading] = useState(false); + const [loadingStandards, setLoadingStandards] = useState(false); + const [loadingGA, setLoadingGA] = useState(false); const [error, setError] = useState(null); const { apiUrl } = useEnvironment(); @@ -142,36 +143,36 @@ export const GapAnalysis = () => { useEffect(() => { const fetchData = async () => { const result = await axios.get(`${apiUrl}/standards`); - setLoading(false); + setLoadingStandards(false); setStandardOptions( standardOptionsDefault.concat(result.data.sort().map((x) => ({ key: x, text: x, value: x }))) ); }; - setLoading(true); + setLoadingStandards(true); fetchData().catch((e) => { - setLoading(false); + setLoadingStandards(false); setError(e.response.data.message ?? e.message); }); - }, [setStandardOptions, setLoading, setError]); + }, [setStandardOptions, setLoadingStandards, setError]); useEffect(() => { const fetchData = async () => { const result = await axios.get( `${apiUrl}/map_analysis?standard=${BaseStandard}&standard=${CompareStandard}` ); - setLoading(false); + setLoadingGA(false); setGapAnalysis(result.data); }; if (!BaseStandard || !CompareStandard || BaseStandard === CompareStandard) return; setGapAnalysis(undefined); - setLoading(true); + setLoadingGA(true); fetchData().catch((e) => { - setLoading(false); + setLoadingGA(false); setError(e.response.data.message ?? e.message); }); - }, [BaseStandard, CompareStandard, setGapAnalysis, setLoading, setError]); + }, [BaseStandard, CompareStandard, setGapAnalysis, setLoadingGA, setError]); const handleAccordionClick = (e, titleProps) => { const { index } = titleProps; @@ -226,7 +227,7 @@ export const GapAnalysis = () => { - + {gapAnalysis && ( <> {Object.keys(gapAnalysis)