mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
2988d5e429
* chore: handled redirection when user is not logged in * dev: handle url redirection in space app * dev: remove user from redis on successful code matching
30 lines
754 B
TypeScript
30 lines
754 B
TypeScript
"use client";
|
|
|
|
import { observer } from "mobx-react-lite";
|
|
import useSWR from "swr";
|
|
// components
|
|
import { UserLoggedIn } from "@/components/account";
|
|
import { LogoSpinner } from "@/components/common";
|
|
import { AuthView } from "@/components/views";
|
|
// hooks
|
|
import { useUser } from "@/hooks/store";
|
|
|
|
function HomePage() {
|
|
const { data: currentUser, fetchCurrentUser, isAuthenticated, isLoading } = useUser();
|
|
|
|
useSWR("CURRENT_USER", () => fetchCurrentUser(), {
|
|
errorRetryCount: 0,
|
|
revalidateIfStale: false,
|
|
revalidateOnFocus: false,
|
|
refreshWhenHidden: false,
|
|
});
|
|
|
|
if (isLoading) return <LogoSpinner />;
|
|
|
|
if (currentUser && isAuthenticated) return <UserLoggedIn />;
|
|
|
|
return <AuthView />;
|
|
}
|
|
|
|
export default observer(HomePage);
|