diff --git a/src/pages/sign-in.tsx b/src/pages/sign-in.tsx index 95a91a5..500f220 100644 --- a/src/pages/sign-in.tsx +++ b/src/pages/sign-in.tsx @@ -1,21 +1,16 @@ -import { GetServerSideProps, type NextPage } from "next"; +import { + type GetServerSidePropsContext, + type InferGetServerSidePropsType, +} from "next"; import Head from "next/head"; -import { api } from "~/utils/api"; -import { type AppProps } from "next/app"; import { getProviders, signIn } from "next-auth/react"; import { getServerSession } from "next-auth"; import { authOptions } from "~/server/auth"; -interface Props { - providers: AppProps; -} - -const SignIn: NextPage = ({ providers }: Props) => { - const hello = api.example.hello.useQuery({ text: "from tRPC" }); - - console.log(providers); - +const SignIn = ({ + providers, +}: InferGetServerSidePropsType) => { return ( <> @@ -30,48 +25,22 @@ const SignIn: NextPage = ({ providers }: Props) => { Sign in with
- - - + {Object.values(providers).map((provider) => ( + + ))}

By signing in, you agree to our{" "} @@ -87,7 +56,7 @@ const SignIn: NextPage = ({ providers }: Props) => { export default SignIn; -export const getServerSideProps: GetServerSideProps = async (context) => { +export async function getServerSideProps(context: GetServerSidePropsContext) { const session = await getServerSession(context.req, context.res, authOptions); // If the user is already logged in, redirect. @@ -98,7 +67,8 @@ export const getServerSideProps: GetServerSideProps = async (context) => { } const providers = await getProviders(); + return { - props: { providers }, + props: { providers: providers ?? [] }, }; -}; +}