mhunt_account_dash/pages/index.tsx
2024-09-26 15:04:52 +05:30

72 lines
2.5 KiB
TypeScript

import { useLogin } from "@privy-io/react-auth";
import { PrivyClient } from "@privy-io/server-auth";
import { GetServerSideProps } from "next";
import Head from "next/head";
import { useRouter } from "next/router";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faRocket } from "@fortawesome/free-solid-svg-icons";
import Button from "../components/LoginButton";
export const getServerSideProps: GetServerSideProps = async ({ req }) => {
const cookieAuthToken = req.cookies["privy-token"];
if (!cookieAuthToken) return { props: {} };
const PRIVY_APP_ID = process.env.NEXT_PUBLIC_PRIVY_APP_ID;
const PRIVY_APP_SECRET = process.env.PRIVY_APP_SECRET;
const client = new PrivyClient(PRIVY_APP_ID!, PRIVY_APP_SECRET!);
try {
const claims = await client.verifyAuthToken(cookieAuthToken);
console.log({ claims });
return {
props: {},
redirect: { destination: "/dashboard", permanent: false },
};
} catch (error) {
return { props: {} };
}
};
export default function LoginPage() {
const router = useRouter();
const { login } = useLogin({
onComplete: () => router.push("/dashboard"),
});
return (
<>
<Head>
<title>Login · W3B Games</title>
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"
rel="stylesheet"
/>
</Head>
<main className="flex min-h-screen w-full relative overflow-hidden font-inter">
<div className="flex flex-col w-full h-screen">
<div className="flex-[3] bg-[#0F0F0F]"></div>
<div className="flex-[4] bg-black"></div>
</div>
<div className="absolute inset-x-0 top-0 flex items-center justify-center pointer-events-none h-[86vh]">
<h2 className="text-[10vw] font-bold whitespace-nowrap bg-clip-text text-transparent bg-[linear-gradient(to_bottom,black_50%,#0F0F0F_50%)]">METAHUNT</h2>
</div>
<div className="absolute inset-x-10 top-10 flex w-24 h-24">
<img src="./logos/logo.png"/>
</div>
<div className="absolute inset-0 flex justify-center items-center">
<div className="text-center w-full px-6 relative top-[10vh]">
<div className="mt-6 flex justify-center ">
<div className="bg-blue-500 rounded-full hover:scale-110 transition-all duration-300">
<Button onClick={login} text="LOG IN / REGISTER" />
</div>
</div>
</div>
</div>
</main>
</>
);
}