plane/space/app/page.tsx
2024-05-16 04:03:43 +05:30

28 lines
643 B
TypeScript

"use client";
import { observer } from "mobx-react-lite";
import useSWR from "swr";
// components
import { UserLoggedIn } from "@/components/accounts";
import { LogoSpinner } from "@/components/common";
import { AuthView } from "@/components/views";
// hooks
import { useUser } from "@/hooks/store";
function HomePage() {
const { fetchCurrentUser, isAuthenticated, isLoading } = useUser();
useSWR("CURRENT_USER", () => fetchCurrentUser(), { errorRetryCount: 0 });
if (isLoading) {
return <LogoSpinner />;
}
if (isAuthenticated) {
return <UserLoggedIn />;
}
return <AuthView />;
}
export default observer(HomePage);