Add basic homepage content
parent
d82dc10d74
commit
38cbb42b2c
131
pages/index.tsx
131
pages/index.tsx
|
@ -1,11 +1,20 @@
|
||||||
import Head from 'next/head'
|
import Head from 'next/head';
|
||||||
import Shell from '../components/Shell'
|
import Link from 'next/link';
|
||||||
import { signIn, useSession } from 'next-auth/client'
|
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();
|
const [ session, loading ] = useSession();
|
||||||
|
|
||||||
if (session) {
|
if (loading) {
|
||||||
|
return <p className="text-gray-400">Loading...</p>;
|
||||||
|
} else {
|
||||||
|
if (!session) {
|
||||||
|
window.location.href = "/auth/login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<div>
|
<div>
|
||||||
<Head>
|
<Head>
|
||||||
|
@ -14,52 +23,82 @@ export default function Home() {
|
||||||
</Head>
|
</Head>
|
||||||
|
|
||||||
<Shell heading="Dashboard">
|
<Shell heading="Dashboard">
|
||||||
|
<div className="grid grid-cols-3 gap-4">
|
||||||
|
<div className="col-span-2">
|
||||||
|
<div className="bg-white shadow sm:rounded-lg">
|
||||||
|
<div className="px-4 py-5 sm:p-6">
|
||||||
|
<h3 className="text-lg leading-6 font-medium text-gray-900">
|
||||||
|
Welcome to Calendso!
|
||||||
|
</h3>
|
||||||
|
<div className="mt-2 max-w-xl text-sm text-gray-500">
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="mt-3 text-sm">
|
||||||
|
<Link href="/integrations">
|
||||||
|
<a className="font-medium text-blue-600 hover:text-blue-500"> Set up your first integration <span aria-hidden="true">→</span></a>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
<div className="bg-white rounded-lg shadow px-5 py-6 sm:px-6">
|
<div className="bg-white rounded-lg shadow px-5 py-6 sm:px-6">
|
||||||
<div className="border-4 border-dashed border-gray-200 rounded-lg h-96"></div>
|
<div className="mb-8 sm:flex sm:items-center sm:justify-between">
|
||||||
|
<h3 className="text-lg leading-6 font-medium text-gray-900">
|
||||||
|
Your integrations
|
||||||
|
</h3>
|
||||||
|
<div className="mt-3 sm:mt-0 sm:ml-4">
|
||||||
|
<Link href="/integrations">
|
||||||
|
<a className="text-sm text-gray-400">View more</a>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ul className="divide-y divide-gray-200">
|
||||||
|
{props.credentials.map((integration) =>
|
||||||
|
<li className="pb-4 flex">
|
||||||
|
{integration.type == 'google_calendar' && <img className="h-10 w-10 mr-2" src="integrations/google-calendar.png" alt="Google Calendar" />}
|
||||||
|
<div className="ml-3">
|
||||||
|
{integration.type == 'google_calendar' && <p className="text-sm font-medium text-gray-900">Google Calendar</p>}
|
||||||
|
{integration.type == 'google_calendar' && <p className="text-sm text-gray-500">Calendar Integration</p>}
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Shell>
|
</Shell>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else {
|
}
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Head>
|
|
||||||
<title>Calendso</title>
|
|
||||||
<link rel="icon" href="/favicon.ico" />
|
|
||||||
</Head>
|
|
||||||
|
|
||||||
<main className="text-center">
|
export async function getServerSideProps(context) {
|
||||||
<div className="fixed z-10 inset-0 overflow-y-auto" aria-labelledby="modal-title" role="dialog" aria-modal="true">
|
const session = await getSession(context);
|
||||||
<div className="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
|
|
||||||
<span className="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">​</span>
|
let credentials = [];
|
||||||
<div className="inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-sm sm:w-full sm:p-6">
|
|
||||||
<div>
|
if (session) {
|
||||||
<div className="mx-auto flex items-center justify-center h-12 w-12 rounded-full bg-blue-100">
|
const user = await prisma.user.findFirst({
|
||||||
<svg className="h-6 w-6 text-blue-600" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
where: {
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
|
email: session.user.email,
|
||||||
</svg>
|
},
|
||||||
</div>
|
select: {
|
||||||
<div className="mt-3 text-center sm:mt-5">
|
id: true
|
||||||
<h3 className="text-lg leading-6 font-medium text-gray-900" id="modal-title">
|
}
|
||||||
Sign into your account
|
});
|
||||||
</h3>
|
|
||||||
<div className="mt-2">
|
credentials = await prisma.credential.findMany({
|
||||||
<p className="text-sm text-gray-500">
|
where: {
|
||||||
Sign into your account to manage your bookings and other settings.
|
userId: user.id,
|
||||||
</p>
|
},
|
||||||
</div>
|
select: {
|
||||||
</div>
|
type: true
|
||||||
</div>
|
}
|
||||||
<div className="mt-5 sm:mt-6">
|
});
|
||||||
<button onClick={() => signIn()} type="button" className="inline-flex justify-center w-full rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:text-sm">
|
}
|
||||||
Login to your account
|
return {
|
||||||
</button>
|
props: {credentials}, // will be passed to the page component as props
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue