2024-05-15 22:33:43 +00:00
|
|
|
"use client";
|
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
import useSWR from "swr";
|
2024-05-14 08:56:54 +00:00
|
|
|
// components
|
2024-05-16 11:47:04 +00:00
|
|
|
import { UserLoggedIn } from "@/components/account";
|
2024-05-15 22:33:43 +00:00
|
|
|
import { LogoSpinner } from "@/components/common";
|
2024-05-14 08:56:54 +00:00
|
|
|
import { AuthView } from "@/components/views";
|
2024-05-15 22:33:43 +00:00
|
|
|
// hooks
|
|
|
|
import { useUser } from "@/hooks/store";
|
2024-05-14 08:56:54 +00:00
|
|
|
|
2024-05-15 22:33:43 +00:00
|
|
|
function HomePage() {
|
|
|
|
const { fetchCurrentUser, isAuthenticated, isLoading } = useUser();
|
2024-05-14 08:56:54 +00:00
|
|
|
|
2024-05-15 22:33:43 +00:00
|
|
|
useSWR("CURRENT_USER", () => fetchCurrentUser(), { errorRetryCount: 0 });
|
2024-05-14 08:56:54 +00:00
|
|
|
|
2024-05-15 22:33:43 +00:00
|
|
|
if (isLoading) {
|
|
|
|
return <LogoSpinner />;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isAuthenticated) {
|
2024-05-14 08:56:54 +00:00
|
|
|
return <UserLoggedIn />;
|
|
|
|
}
|
|
|
|
|
2024-05-14 20:55:38 +00:00
|
|
|
return <AuthView />;
|
2024-05-14 08:56:54 +00:00
|
|
|
}
|
2024-05-15 22:33:43 +00:00
|
|
|
|
|
|
|
export default observer(HomePage);
|