plane/space/app/page.tsx

30 lines
754 B
TypeScript
Raw Normal View History

2024-05-15 22:33:43 +00:00
"use client";
2024-05-15 22:33:43 +00:00
import { observer } from "mobx-react-lite";
import useSWR from "swr";
// components
import { UserLoggedIn } from "@/components/account";
2024-05-15 22:33:43 +00:00
import { LogoSpinner } from "@/components/common";
import { AuthView } from "@/components/views";
2024-05-15 22:33:43 +00:00
// hooks
import { useUser } from "@/hooks/store";
2024-05-15 22:33:43 +00:00
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 />;
2024-05-15 22:33:43 +00:00
if (currentUser && isAuthenticated) return <UserLoggedIn />;
2024-05-14 20:55:38 +00:00
return <AuthView />;
}
2024-05-15 22:33:43 +00:00
export default observer(HomePage);