From 3bcc4b86e51a1a23aebce646f846aa9c5a088de5 Mon Sep 17 00:00:00 2001 From: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Date: Mon, 7 Mar 2022 15:48:51 +0000 Subject: [PATCH] Back Button Events - [2058] (#2074) * Back Button Events - [2058] * Fixing URL Co-authored-by: Bailey Pumfleet --- .../booking/pages/AvailabilityPage.tsx | 23 ++++++++++++++++--- apps/web/pages/[user]/[type].tsx | 1 + apps/web/pages/team/[slug]/[type].tsx | 1 + 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/apps/web/components/booking/pages/AvailabilityPage.tsx b/apps/web/components/booking/pages/AvailabilityPage.tsx index 5c58b9b8..0966daa5 100644 --- a/apps/web/components/booking/pages/AvailabilityPage.tsx +++ b/apps/web/components/booking/pages/AvailabilityPage.tsx @@ -1,5 +1,12 @@ // Get router variables -import { ChevronDownIcon, ChevronUpIcon, ClockIcon, CreditCardIcon, GlobeIcon } from "@heroicons/react/solid"; +import { + ArrowLeftIcon, + ChevronDownIcon, + ChevronUpIcon, + ClockIcon, + CreditCardIcon, + GlobeIcon, +} from "@heroicons/react/solid"; import * as Collapsible from "@radix-ui/react-collapsible"; import { useContracts } from "contexts/contractsContext"; import dayjs, { Dayjs } from "dayjs"; @@ -11,6 +18,7 @@ import { FormattedNumber, IntlProvider } from "react-intl"; import { asStringOrNull } from "@lib/asStringOrNull"; import { timeZone } from "@lib/clock"; +import { BASE_URL } from "@lib/config/constants"; import { useLocale } from "@lib/hooks/useLocale"; import useTheme from "@lib/hooks/useTheme"; import { isBrandingHidden } from "@lib/isBrandingHidden"; @@ -33,7 +41,7 @@ dayjs.extend(customParseFormat); type Props = AvailabilityTeamPageProps | AvailabilityPageProps; -const AvailabilityPage = ({ profile, eventType, workingHours }: Props) => { +const AvailabilityPage = ({ profile, eventType, workingHours, previousPage }: Props) => { const router = useRouter(); const { rescheduleUid } = router.query; const { isReady, Theme } = useTheme(profile.theme); @@ -168,7 +176,7 @@ const AvailabilityPage = ({ profile, eventType, workingHours }: Props) => {
{

{eventType.description}

+ {previousPage === `${BASE_URL}/${profile.slug}` && ( +
+ router.back()} + /> +

Go Back

+
+ )}
eventType: eventTypeObject, workingHours, trpcState: ssr.dehydrate(), + previousPage: context.req.headers.referer ?? null, }, }; }; diff --git a/apps/web/pages/team/[slug]/[type].tsx b/apps/web/pages/team/[slug]/[type].tsx index d50c124d..1c090522 100644 --- a/apps/web/pages/team/[slug]/[type].tsx +++ b/apps/web/pages/team/[slug]/[type].tsx @@ -111,6 +111,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) => date: dateParam, eventType: eventTypeObject, workingHours, + previousPage: context.req.headers.referer ?? null, }, }; };