diff --git a/lib/event.ts b/lib/event.ts index 30cb201c..82b969d2 100644 --- a/lib/event.ts +++ b/lib/event.ts @@ -1,3 +1,8 @@ -export function getEventName(name: string, eventTitle: string, eventNameTemplate?: string) { +export function getEventName( + name: string | string[] | undefined, + eventTitle: string, + eventNameTemplate: string | null +) { + if (!name || !(typeof name === "string")) name = ""; // If name is not set or is not of proper type return eventNameTemplate ? eventNameTemplate.replace("{USER}", name) : eventTitle + " with " + name; } diff --git a/lib/hooks/useTheme.tsx b/lib/hooks/useTheme.tsx index 99ad205e..bbea7805 100644 --- a/lib/hooks/useTheme.tsx +++ b/lib/hooks/useTheme.tsx @@ -11,6 +11,8 @@ export default function useTheme(theme?: Maybe) { } if (!theme && window.matchMedia("(prefers-color-scheme: dark)").matches) { document.documentElement.classList.add("dark"); + } else if (!theme) { + /** Uncovered case */ } else { document.documentElement.classList.add(theme); } diff --git a/pages/success.tsx b/pages/success.tsx index 6a87e2e8..b708b237 100644 --- a/pages/success.tsx +++ b/pages/success.tsx @@ -1,6 +1,5 @@ import { CheckIcon } from "@heroicons/react/outline"; import { ClockIcon } from "@heroicons/react/solid"; -import { EventType } from "@prisma/client"; import dayjs from "dayjs"; import timezone from "dayjs/plugin/timezone"; import toArray from "dayjs/plugin/toArray"; @@ -40,7 +39,7 @@ export default function Success(props: inferSSRProps) const eventName = getEventName(name, props.eventType.title, props.eventType.eventName); function eventLink(): string { - const optional = {}; + const optional: { location?: string | string[] } = {}; if (location) { optional["location"] = location; } @@ -53,7 +52,8 @@ export default function Success(props: inferSSRProps) .map((v, i) => (i === 1 ? v + 1 : v)), startInputType: "utc", title: eventName, - description: props.eventType.description, + description: props.eventType.description ? props.eventType.description : undefined, + /** formatted to required type of description ^ */ duration: { minutes: props.eventType.length }, ...optional, }); @@ -62,38 +62,38 @@ export default function Success(props: inferSSRProps) throw event.error; } - return encodeURIComponent(event.value); + return encodeURIComponent(event.value ? event.value : false); } const needsConfirmation = props.eventType.requiresConfirmation && reschedule != "true"; return ( (isReady && ( -
+
-
-
-
-