Move packages/apps back
This commit is contained in:
parent
6eaaf8e9be
commit
5535d6b575
348 changed files with 0 additions and 0 deletions
20
apps/metamigo-frontend/components/Auth.tsx
Normal file
20
apps/metamigo-frontend/components/Auth.tsx
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { FC, PropsWithChildren, useEffect } from "react";
|
||||
import { CircularProgress } from "@material-ui/core";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
export const Auth: FC<PropsWithChildren> = ({ children }) => {
|
||||
const router = useRouter();
|
||||
const { data: session, status: loading } = useSession();
|
||||
useEffect(() => {
|
||||
if (!session && !loading) {
|
||||
router.push("/login");
|
||||
}
|
||||
}, [session, loading]);
|
||||
|
||||
if (loading) {
|
||||
return <CircularProgress />;
|
||||
}
|
||||
|
||||
return <>{children}</>;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue