From 91fca7477d1436673ee8fc4bffa1fc47e72e6c49 Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Fri, 29 Oct 2021 00:06:37 +0100 Subject: [PATCH] Fixed opt-in layout plus some tweaks (#1067) --- pages/success.tsx | 52 ++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/pages/success.tsx b/pages/success.tsx index adcbf478..9ec84739 100644 --- a/pages/success.tsx +++ b/pages/success.tsx @@ -10,7 +10,7 @@ import Link from "next/link"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; -import { asStringOrNull } from "@lib/asStringOrNull"; +import { asStringOrThrow, asStringOrNull } from "@lib/asStringOrNull"; import { getEventName } from "@lib/event"; import { useLocale } from "@lib/hooks/useLocale"; import useTheme from "@lib/hooks/useTheme"; @@ -31,7 +31,7 @@ export default function Success(props: inferSSRProps) const { location, name, reschedule } = router.query; const [is24h, setIs24h] = useState(false); - const [date, setDate] = useState(dayjs.utc(asStringOrNull(router.query.date))); + const [date, setDate] = useState(dayjs.utc(asStringOrThrow(router.query.date))); const { isReady } = useTheme(props.profile.theme); useEffect(() => { @@ -48,11 +48,13 @@ export default function Success(props: inferSSRProps) } const event = createEvent({ - start: date - .utc() - .toArray() - .slice(0, 6) - .map((v, i) => (i === 1 ? v + 1 : v)) as any, // <-- FIXME fix types, not sure what's going on here + start: [ + date.toDate().getUTCFullYear(), + date.toDate().getUTCMonth(), + date.toDate().getUTCDate(), + date.toDate().getUTCHours(), + date.toDate().getUTCMinutes(), + ], startInputType: "utc", title: eventName, description: props.eventType.description ? props.eventType.description : undefined, @@ -77,20 +79,20 @@ export default function Success(props: inferSSRProps) title={needsConfirmation ? t("booking_submitted") : t("booking_confirmed")} description={needsConfirmation ? t("booking_submitted") : t("booking_confirmed")} /> -
-
-
+
+
+