@@ -48,19 +48,19 @@ export default function Shell(props) {
@@ -71,7 +71,7 @@ export default function Shell(props) {
{
diff --git a/pages/api/auth/[...nextauth].tsx b/pages/api/auth/[...nextauth].tsx
index 3bfbb08d..ad65f66f 100644
--- a/pages/api/auth/[...nextauth].tsx
+++ b/pages/api/auth/[...nextauth].tsx
@@ -36,7 +36,7 @@ export default NextAuth({
throw new Error('Incorrect password');
}
- return {id: user.id, username: user.username, email: user.email, name: user.name};
+ return {id: user.id, username: user.username, email: user.email, name: user.name, image: user.avatar};
}
})
],
diff --git a/pages/availability/index.tsx b/pages/availability/index.tsx
index 32664592..8d682ca2 100644
--- a/pages/availability/index.tsx
+++ b/pages/availability/index.tsx
@@ -110,7 +110,7 @@ export default function Availability(props) {
Event Types
-
diff --git a/pages/index.tsx b/pages/index.tsx
index 7501b905..7abd81cf 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -3,14 +3,66 @@ import Link from 'next/link';
import prisma from '../lib/prisma';
import Shell from '../components/Shell';
import { signIn, useSession, getSession } from 'next-auth/client';
+import { ClockIcon, CheckIcon, InformationCircleIcon } from '@heroicons/react/outline';
+
+function classNames(...classes) {
+ return classes.filter(Boolean).join(' ')
+}
export default function Home(props) {
- const [ session, loading ] = useSession();
+ const [session, loading] = useSession();
if (loading) {
return
Loading...
;
}
- return(
+ function convertMinsToHrsMins(mins) {
+ let h = Math.floor(mins / 60);
+ let m = mins % 60;
+ h = h < 10 ? '0' + h : h;
+ m = m < 10 ? '0' + m : m;
+ return `${h}:${m}`;
+ }
+
+ const stats = [
+ { name: 'Event Types', stat: props.eventTypeCount },
+ { name: 'Integrations', stat: props.integrationCount },
+ { name: 'Available Hours', stat: (props.user.endTime - props.user.startTime) / 60 + ' hours' },
+ ];
+
+ let timeline = [];
+
+ if (session) {
+ timeline = [
+ {
+ id: 1,
+ content: 'Add your first',
+ target: 'integration',
+ href: '/integrations',
+ icon: props.integrationCount != 0 ? CheckIcon : InformationCircleIcon,
+ iconBackground: props.integrationCount != 0 ? 'bg-green-400' : 'bg-gray-400',
+ },
+ {
+ id: 2,
+ content: 'Add one or more',
+ target: 'event types',
+ href: '/availability',
+ icon: props.eventTypeCount != 0 ? CheckIcon : InformationCircleIcon,
+ iconBackground: props.eventTypeCount != 0 ? 'bg-green-400' : 'bg-gray-400',
+ },
+ {
+ id: 3,
+ content: 'Complete your',
+ target: 'profile',
+ href: '/settings/profile',
+ icon: session.user.image ? CheckIcon : InformationCircleIcon,
+ iconBackground: session.user.image ? 'bg-green-400' : 'bg-gray-400',
+ },
+ ];
+ } else {
+ timeline = [];
+ }
+
+ return (
Calendso
@@ -20,26 +72,124 @@ export default function Home(props) {
-
-
+
+
- Welcome to Calendso!
+ Your stats
-
-
- 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.
-
+
+
+ {stats.map((item) => (
+
+
- {item.name}
+
-
+
+ {item.stat}
+
+
+
+ ))}
+
+
+
+
+
+ Your event types
+
+
+
+ {props.eventTypes.map((type) => (
+ -
+
+
+
+
+
{type.title}
+
in {type.description}
+
+
+
+
+
+ {type.length} minutes
+
+
+
+
+
+
+
+
+ ))}
+
+
+
+
+
+
Getting started
+
Steps you should take to get started with Calendso.
-
-
-
Set up your first integration →
-
+
+
+
+ {timeline.map((event, eventIdx) => (
+ -
+
+ {eventIdx !== timeline.length - 1 ? (
+
+ ) : null}
+
+
+
+ ))}
+
+
+
+
+
Offering time slots between {convertMinsToHrsMins(props.user.startTime)} and {convertMinsToHrsMins(props.user.endTime)}
+
+
+
Your integrations
@@ -69,6 +219,39 @@ export default function Home(props) {
}
+
+
+
+ Your event types
+
+
+
+
+ {props.eventTypes.map((type) => (
+ -
+
+
+
+ {type.length} minutes
+
+
+
+ ))}
+
+
@@ -79,15 +262,22 @@ export default function Home(props) {
export async function getServerSideProps(context) {
const session = await getSession(context);
+ let user = [];
let credentials = [];
+ let eventTypes = [];
+
+ let eventTypeCount = 0;
+ let integrationCount = 0;
if (session) {
- const user = await prisma.user.findFirst({
+ user = await prisma.user.findFirst({
where: {
email: session.user.email,
},
select: {
- id: true
+ id: true,
+ startTime: true,
+ endTime: true
}
});
@@ -99,8 +289,26 @@ export async function getServerSideProps(context) {
type: true
}
});
+
+ eventTypes = await prisma.eventType.findMany({
+ where: {
+ userId: user.id,
+ }
+ });
+
+ eventTypeCount = await prisma.eventType.count({
+ where: {
+ userId: session.user.id
+ }
+ });
+
+ integrationCount = await prisma.credential.count({
+ where: {
+ userId: session.user.id
+ }
+ });
}
return {
- props: {credentials}, // will be passed to the page component as props
+ props: { user, credentials, eventTypes, eventTypeCount, integrationCount }, // will be passed to the page component as props
}
}
\ No newline at end of file