Skip to content

Commit

Permalink
[SELC-4581] feat: Code optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
loremedda committed Apr 5, 2024
1 parent 802f243 commit dc64e29
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/pages/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,22 @@ const Dashboard = () => {
});

useEffect(() => {
if (party?.partyId) {
setLoading(true);
const redirectPath = party.delegation
? DASHBOARD_ROUTES.TECHPARTNER.path
: window.location.pathname;
history.push(resolvePathVariables(redirectPath, { partyId: party?.partyId ?? '' }));
setLoading(false);
const notOverview =
window.location.pathname.endsWith('users') ||
window.location.pathname.endsWith('groups') ||
window.location.pathname.endsWith('admin');

setLoading(true);

if (party?.partyId && !notOverview) {
const route = party?.delegation
? resolvePathVariables(DASHBOARD_ROUTES.TECHPARTNER.path, { partyId: party?.partyId ?? '' })
: resolvePathVariables(DASHBOARD_ROUTES.OVERVIEW.path, { partyId: party?.partyId ?? '' });

history.push(route);
}

setLoading(false);
}, [party?.partyId]);

return party && products ? (
Expand Down

0 comments on commit dc64e29

Please sign in to comment.