plane/apps/app/pages/index.tsx

26 lines
699 B
TypeScript
Raw Normal View History

2022-11-19 14:21:26 +00:00
import React, { useEffect } from "react";
// next
import type { NextPage } from "next";
import { useRouter } from "next/router";
// hooks
import useUser from "lib/hooks/useUser";
const Home: NextPage = () => {
const router = useRouter();
const { user, isUserLoading, activeWorkspace, workspaces } = useUser();
2022-11-19 14:21:26 +00:00
2022-11-25 07:36:34 +00:00
useEffect(() => {
if (!isUserLoading && (!user || user === null)) router.push("/signin");
}, [isUserLoading, user, router]);
2022-11-19 14:21:26 +00:00
useEffect(() => {
if (!activeWorkspace && workspaces?.length === 0) router.push("/invitations");
else if (activeWorkspace) router.push(`/workspace/`);
}, [activeWorkspace, router, workspaces]);
return <></>;
};
export default Home;