feat(ui): removed workspace context redirect and added redirect when project is deleted

This commit is contained in:
akhilmhdh
2023-02-04 14:24:10 +05:30
parent 0ac40acc40
commit e72e6cf2b7
2 changed files with 7 additions and 12 deletions
@@ -1,4 +1,4 @@
import { createContext, ReactNode, useContext, useEffect, useMemo } from 'react';
import { createContext, ReactNode, useContext, useMemo } from 'react';
import { useRouter } from 'next/router';
import { useGetUserWorkspaces } from '@app/hooks/api';
@@ -30,15 +30,6 @@ export const WorkspaceProvider = ({ children }: Props): JSX.Element => {
};
}, [ws, workspaceId, isLoading]);
useEffect(() => {
// not loading and current workspace is empty
// ws empty means user has no access to the ws
// push to the first workspace
if (!isLoading && !value?.currentWorkspace?._id) {
router.push(`/dashboard/${value.workspaces?.[0]?._id}`);
}
}, [value?.currentWorkspace?._id, isLoading, value.workspaces?.[0]?._id, router.pathname]);
return <WorkspaceContext.Provider value={value}>{children}</WorkspaceContext.Provider>;
};