From 8340fce157319f3aabf4cfa358721414c270f7d2 Mon Sep 17 00:00:00 2001 From: Peer Richelsen Date: Tue, 3 Aug 2021 10:30:35 +0200 Subject: [PATCH] extracted classNames into helpers --- components/Settings.tsx | 5 +- components/Shell.tsx | 4 +- components/booking/TimeOptions.tsx | 5 +- lib/classNames.ts | 3 + pages/bookings/index.tsx | 97 ++++++++++++++++++++++-------- pages/cancel/[uid].tsx | 4 -- pages/cancel/success.tsx | 7 --- pages/event-types/index.tsx | 5 +- pages/integrations/index.tsx | 5 +- 9 files changed, 79 insertions(+), 56 deletions(-) create mode 100644 lib/classNames.ts diff --git a/components/Settings.tsx b/components/Settings.tsx index 6c182c7500..94f38e93ed 100644 --- a/components/Settings.tsx +++ b/components/Settings.tsx @@ -1,10 +1,7 @@ import Link from "next/link"; import { CreditCardIcon, UserIcon, CodeIcon, KeyIcon, UserGroupIcon } from "@heroicons/react/solid"; import { useRouter } from "next/router"; - -function classNames(...classes) { - return classes.filter(Boolean).join(" "); -} +import classNames from "@lib/classNames"; export default function SettingsShell(props) { const router = useRouter(); diff --git a/components/Shell.tsx b/components/Shell.tsx index eaa9450222..3a20d701ba 100644 --- a/components/Shell.tsx +++ b/components/Shell.tsx @@ -17,9 +17,7 @@ import { } from "@heroicons/react/solid"; import Logo from "./Logo"; -function classNames(...classes) { - return classes.filter(Boolean).join(" "); -} + export default function Shell(props) { const router = useRouter(); diff --git a/components/booking/TimeOptions.tsx b/components/booking/TimeOptions.tsx index 52023e791f..59cd7a2e13 100644 --- a/components/booking/TimeOptions.tsx +++ b/components/booking/TimeOptions.tsx @@ -2,10 +2,7 @@ import { Switch } from "@headlessui/react"; import TimezoneSelect from "react-timezone-select"; import { useEffect, useState } from "react"; import { is24h, timeZone } from "../../lib/clock"; - -function classNames(...classes) { - return classes.filter(Boolean).join(" "); -} +import classNames from "@lib/classNames"; const TimeOptions = (props) => { const [selectedTimeZone, setSelectedTimeZone] = useState(""); diff --git a/lib/classNames.ts b/lib/classNames.ts new file mode 100644 index 0000000000..5cf822d535 --- /dev/null +++ b/lib/classNames.ts @@ -0,0 +1,3 @@ +export default function classNames(...classes) { + return classes.filter(Boolean).join(" "); +} diff --git a/pages/bookings/index.tsx b/pages/bookings/index.tsx index 58fbe412b8..6612f7d389 100644 --- a/pages/bookings/index.tsx +++ b/pages/bookings/index.tsx @@ -4,6 +4,9 @@ import { getSession, useSession } from "next-auth/client"; import Shell from "../../components/Shell"; import { useRouter } from "next/router"; import dayjs from "dayjs"; +import {Fragment} from 'react'; +import {Menu, Transition} from '@headlessui/react'; +import {DotsHorizontalIcon, ExternalLinkIcon, LinkIcon} from '@heroicons/react/solid'; export default function Bookings({ bookings }) { @@ -41,11 +44,6 @@ export default function Bookings({ bookings }) { - +
- Person - @@ -73,35 +71,20 @@ export default function Bookings({ bookings }) { Unconfirmed )} -
- {booking.attendees[0].name} +
+ {booking.title}
{booking.attendees[0].email}
-
- {booking.title} -
- -
-
- {booking.title} -
-
- You and {booking.attendees[0].name} -
{dayjs(booking.startTime).format("D MMMM YYYY")}
- {dayjs(booking.startTime).format("HH:mm")} - {dayjs(booking.endTime).format("HH:mm")} + {dayjs(booking.startTime).format("HH:mm")} -{" "} + {dayjs(booking.endTime).format("HH:mm")}
-
{!booking.confirmed && !booking.rejected && ( <> @@ -129,6 +112,68 @@ export default function Bookings({ bookings }) { className="text-xs sm:text-sm inline-flex items-center px-4 py-2 border-transparent font-medium rounded-sm shadow-sm text-neutral-700 bg-white hover:bg-neutral-100 border border-neutral-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black ml-2"> Reschedule + + {({ open }) => ( + <> +
+ + Open options + +
+ + + +
+ + {({ active }) => ( + + + )} + + + {({ active }) => ( + + )} + +
+
+
+ + )} +
)} {!booking.confirmed && booking.rejected && ( @@ -184,7 +229,7 @@ export async function getServerSideProps(context) { }, }); - const bookings = b.map(booking=>{ + const bookings = b.reverse().map(booking=>{ return ({...booking, startTime:booking.startTime.toISOString(), endTime:booking.endTime.toISOString(),}) }); diff --git a/pages/cancel/[uid].tsx b/pages/cancel/[uid].tsx index a415e47023..11724e01b0 100644 --- a/pages/cancel/[uid].tsx +++ b/pages/cancel/[uid].tsx @@ -15,10 +15,6 @@ dayjs.extend(isBetween); dayjs.extend(utc); dayjs.extend(timezone); -function classNames(...classes) { - return classes.filter(Boolean).join(' ') -} - export default function Type(props) { // Get router variables const router = useRouter(); diff --git a/pages/cancel/success.tsx b/pages/cancel/success.tsx index 749de20e88..f221603bfd 100644 --- a/pages/cancel/success.tsx +++ b/pages/cancel/success.tsx @@ -1,4 +1,3 @@ -import {useState} from 'react'; import Head from 'next/head'; import prisma from '../../lib/prisma'; import {useRouter} from 'next/router'; @@ -14,16 +13,10 @@ dayjs.extend(isBetween); dayjs.extend(utc); dayjs.extend(timezone); -function classNames(...classes) { - return classes.filter(Boolean).join(' ') -} - export default function Type(props) { // Get router variables const router = useRouter(); - const [is24h, setIs24h] = useState(false); - return (
diff --git a/pages/event-types/index.tsx b/pages/event-types/index.tsx index 93b4e83c04..f78bf5fc72 100644 --- a/pages/event-types/index.tsx +++ b/pages/event-types/index.tsx @@ -7,10 +7,6 @@ import { getSession, useSession } from "next-auth/client"; import { Fragment, useRef, useState } from "react"; import { Menu, Transition } from "@headlessui/react"; -function classNames(...classes) { - return classes.filter(Boolean).join(" "); -} - import { ClockIcon, DotsHorizontalIcon, @@ -21,6 +17,7 @@ import { UserIcon, } from "@heroicons/react/solid"; import Loader from "@components/Loader"; +import classNames from "@lib/classNames"; export default function Availability({ user, types }) { const [session, loading] = useSession(); diff --git a/pages/integrations/index.tsx b/pages/integrations/index.tsx index 3684339436..76c0c39dee 100644 --- a/pages/integrations/index.tsx +++ b/pages/integrations/index.tsx @@ -14,6 +14,7 @@ import { import { InformationCircleIcon } from "@heroicons/react/outline"; import { Switch } from "@headlessui/react"; import Loader from '@components/Loader'; +import classNames from "@lib/classNames"; export default function Home({ integrations }) { const [session, loading] = useSession(); @@ -81,10 +82,6 @@ export default function Home({ integrations }) { } } - function classNames(...classes) { - return classes.filter(Boolean).join(" "); - } - useEffect(loadCalendars, [integrations]); if (loading) {