Skip to content

Commit

Permalink
fix: redownload data on tab click for units and projects
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Dec 4, 2023
1 parent 1ddcf5c commit 8f6ab9c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/pages/Projects/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')]);

Expand Down
9 changes: 9 additions & 0 deletions src/pages/Units/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
);
Expand Down

0 comments on commit 8f6ab9c

Please sign in to comment.