From 8f6ab9c9e565a5d5cf8e89e2c8dc8ac23a1b0d0b Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Mon, 4 Dec 2023 13:36:25 -0500 Subject: [PATCH] fix: redownload data on tab click for units and projects --- src/pages/Projects/index.js | 14 ++++++++++---- src/pages/Units/index.js | 9 +++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/pages/Projects/index.js b/src/pages/Projects/index.js index 62caf104..f61debe6 100644 --- a/src/pages/Projects/index.js +++ b/src/pages/Projects/index.js @@ -171,18 +171,24 @@ const Projects = withTheme(({ theme }) => { const [isImportOfferModalVisible, setIsImportModalVisible] = useState(false); const windowSize = useWindowSize(); + const fetchProjects = () => { + const projectId = searchParams.get('projectId'); + if (projectId) { + dispatch(getProjectData(projectId)); + } + dispatch(getStagingData({ useMockedResponse: false })); + }; + const handleTabChange = useCallback( (event, newValue) => { setTabValue(newValue); + fetchProjects(); }, [setTabValue], ); useEffect(() => { - const projectId = searchParams.get('projectId'); - if (projectId) { - dispatch(getProjectData(projectId)); - } + fetchProjects(); return () => dispatch(clearProjectData()); }, [searchParams.get('projectId')]); diff --git a/src/pages/Units/index.js b/src/pages/Units/index.js index 186fb90a..21e730ce 100644 --- a/src/pages/Units/index.js +++ b/src/pages/Units/index.js @@ -153,9 +153,18 @@ const Units = withTheme(({ theme }) => { const [modalSizeAndPosition, setModalSizeAndPosition] = useState(null); const windowSize = useWindowSize(); + const fetchUnits = () => { + const unitId = searchParams.get('unitId'); + if (unitId) { + dispatch(getUnitData(unitId)); + } + dispatch(getStagingData({ useMockedResponse: false })); + }; + const handleTabChange = useCallback( (event, newValue) => { setTabValue(newValue); + fetchUnits(); }, [setTabValue], );