From f48e604db311a3bc77e80db531a0a58835cba7df Mon Sep 17 00:00:00 2001 From: Peer Richelsen Date: Mon, 2 Aug 2021 19:37:25 +0200 Subject: [PATCH] removed dashboard, redirecting to eventTypes as new default page --- pages/index.tsx | 370 +----------------------------------------------- 1 file changed, 7 insertions(+), 363 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index ec876b44ff..51cf631e92 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,368 +1,12 @@ -import Head from "next/head"; -import Link from "next/link"; -import prisma from "../lib/prisma"; -import Shell from "../components/Shell"; -import { getSession, useSession } from "next-auth/client"; -import { CheckIcon, ClockIcon, InformationCircleIcon } from "@heroicons/react/outline"; -import DonateBanner from "../components/DonateBanner"; - -function classNames(...classes) { - return classes.filter(Boolean).join(" "); +export default function Home() { + return null; } -export default function Home(props) { - const [session, loading] = useSession(); - if (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: Math.round(((props.user.endTime - props.user.startTime) / 60) * 100) / 100 + " 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 - - - - -
-
-
-
-

Your stats

-
-
- {stats.map((item) => ( -
-
{item.name}
-
-
- {item.stat} -
-
-
- ))} -
-
-
-
-

- Your event types -

-
-
    - {props.eventTypes.map((type) => ( -
  • -
    -
    -
    -
    -

    {type.title}

    -

    in {type.description}

    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - Edit - - - - View - - -
    -
  • - ))} - {props.eventTypes.length == 0 && ( -
    -

    You haven't created any event types.

    -
    - )} -
-
-
-
-
-

Getting started

-

- Steps you should take to get started with Calendso. -

-
-
-
-
    - {timeline.map((event, eventIdx) => ( -
  • -
    - {eventIdx !== timeline.length - 1 ? ( -
    -
  • - ))} -
-
-
-
-
-
-
-
-
-

Your day

-
- - Configure - -
-
-
-

- Offering time slots between{" "} - {convertMinsToHrsMins(props.user.startTime)} and{" "} - {convertMinsToHrsMins(props.user.endTime)} -

-
-
-
-
-

- Your integrations -

-
- - View more - -
-
-
    - {props.credentials.map((integration) => ( -
  • - {integration.type == "google_calendar" && ( - Google Calendar - )} - {integration.type == "office365_calendar" && ( - Office 365 / Outlook.com Calendar - )} - {integration.type == "zoom_video" && ( - Zoom - )} -
    - {integration.type == "office365_calendar" && ( -

    Office 365 / Outlook.com Calendar

    - )} - {integration.type == "google_calendar" && ( -

    Google Calendar

    - )} - {integration.type == "zoom_video" && ( -

    Zoom

    - )} - {integration.type.endsWith("_calendar") && ( -

    Calendar Integration

    - )} - {integration.type.endsWith("_video") && ( -

    Video Conferencing

    - )} -
    -
  • - ))} - {props.credentials.length == 0 && ( -
    -

    You haven't added any integrations.

    -
    - )} -
-
-
-
-

- Your event types -

-
- - View more - -
-
- -
-
-
- -
-
- ); -} - -export async function getServerSideProps(context) { - const session = await getSession(context); - - let user = []; - let credentials = []; - let eventTypes = []; - - if (session) { - user = await prisma.user.findFirst({ - where: { - email: session.user.email, - }, - select: { - id: true, - startTime: true, - endTime: true, - }, - }); - - credentials = await prisma.credential.findMany({ - where: { - userId: session.user.id, - }, - select: { - type: true, - }, - }); - - eventTypes = ( - await prisma.eventType.findMany({ - where: { - userId: session.user.id, - }, - }) - ).map((eventType) => { - return { - ...eventType, - periodStartDate: eventType.periodStartDate?.toString() ?? null, - periodEndDate: eventType.periodEndDate?.toString() ?? null, - }; - }); - } +export async function getStaticProps() { return { - props: { - user, - credentials, - eventTypes, - eventTypeCount: eventTypes.length, - integrationCount: credentials.length, - }, // will be passed to the page component as props + redirect: { + destination: "/event-types", + permanent: false, + }, }; }