diff --git a/pages/index.tsx b/pages/index.tsx index c50b3e04d7..90dad23879 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,65 +1,104 @@ -import Head from 'next/head' -import Shell from '../components/Shell' -import { signIn, useSession } from 'next-auth/client' +import Head from 'next/head'; +import Link from 'next/link'; +import prisma from '../lib/prisma'; +import Shell from '../components/Shell'; +import { signIn, useSession, getSession } from 'next-auth/client'; -export default function Home() { +export default function Home(props) { const [ session, loading ] = useSession(); - if (session) { - return ( -
- - Calendso - - - - -
-
-
-
-
- ); + if (loading) { + return

Loading...

; } else { - return ( -
- - Calendso - - + if (!session) { + window.location.href = "/auth/login"; + } + } -
-
-
- -
-
-
- - - -
-
- -
-

- Sign into your account to manage your bookings and other settings. -

-
-
+ return( +
+ + Calendso + + + + +
+
+
+
+

+ Welcome to Calendso! +

+
+

+ Get started by connecting your first calendar integration, enabling us to fetch your availability. Head over to the integrations page, and click the add link. +

-
- +
-
-
- ) - } +
+
+
+

+ Your integrations +

+
+ + View more + +
+
+ +
+
+ + + + ); } + +export async function getServerSideProps(context) { + const session = await getSession(context); + + let credentials = []; + + if (session) { + const user = await prisma.user.findFirst({ + where: { + email: session.user.email, + }, + select: { + id: true + } + }); + + credentials = await prisma.credential.findMany({ + where: { + userId: user.id, + }, + select: { + type: true + } + }); + } + return { + props: {credentials}, // will be passed to the page component as props + } +} \ No newline at end of file