Merge pull request #6 from dakshesh14/main

fix: redirection from index page
This commit is contained in:
Vihar Kurama 2022-11-25 13:29:21 +05:30 committed by GitHub
commit a8bd5751f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View File

@ -131,7 +131,7 @@ export const UserProvider = ({ children }: { children: ReactElement }) => {
<UserContext.Provider
value={{
user: error ? undefined : data,
isUserLoading: !(!!data || !!error),
isUserLoading: Boolean(data === undefined && error === undefined),
mutateUser: mutate,
activeWorkspace: workspaceError ? undefined : activeWorkspace,
mutateWorkspaces: mutateWorkspaces,

View File

@ -1,5 +1,5 @@
{
"name": "trello-clone",
"name": "plane",
"version": "0.1.0",
"private": true,
"scripts": {

View File

@ -10,7 +10,9 @@ const Home: NextPage = () => {
const { user, isUserLoading, activeWorkspace, workspaces } = useUser();
if (!isUserLoading && !user) router.push("/signin");
useEffect(() => {
if (!isUserLoading && (!user || user === null)) router.push("/signin");
}, [isUserLoading, user, router]);
useEffect(() => {
if (!activeWorkspace && workspaces?.length === 0) router.push("/invitations");