From eec2d8ceed0b97a7ab65d886488a82b6a105c081 Mon Sep 17 00:00:00 2001 From: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Date: Mon, 4 Jul 2022 15:26:22 +0100 Subject: [PATCH] Implement profile back button (#3165) * Implement profile backbutton * update slug to use username * Back Button Improvments Co-authored-by: Peer Richelsen --- .../booking/pages/AvailabilityPage.tsx | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/apps/web/components/booking/pages/AvailabilityPage.tsx b/apps/web/components/booking/pages/AvailabilityPage.tsx index 4bbb49d668..232e112540 100644 --- a/apps/web/components/booking/pages/AvailabilityPage.tsx +++ b/apps/web/components/booking/pages/AvailabilityPage.tsx @@ -16,6 +16,7 @@ import { EventType } from "@prisma/client"; import * as Collapsible from "@radix-ui/react-collapsible"; import { useContracts } from "contexts/contractsContext"; import { TFunction } from "next-i18next"; +import Link from "next/link"; import { useRouter } from "next/router"; import { useEffect, useMemo, useState } from "react"; import { FormattedNumber, IntlProvider } from "react-intl"; @@ -30,7 +31,7 @@ import { useIsEmbed, } from "@calcom/embed-core/embed-iframe"; import classNames from "@calcom/lib/classNames"; -import { CAL_URL, WEBAPP_URL } from "@calcom/lib/constants"; +import { CAL_URL, WEBSITE_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { getRecurringFreq } from "@calcom/lib/recurringStrings"; import { localStorage } from "@calcom/lib/webstorage"; @@ -87,23 +88,15 @@ export const locationKeyToString = (location: LocationObject, t: TFunction) => { } }; -const GoBackToPreviousPage = ({ slug }: { slug: string }) => { +const GoBackToPreviousPage = ({ slug, t }: { slug: string; t: TFunction }) => { const router = useRouter(); - const [previousPage, setPreviousPage] = useState(); - useEffect(() => { - setPreviousPage(document.referrer); - }, []); - - return previousPage === `${WEBAPP_URL}/${slug}` ? ( + return (
- router.back()} - /> -

Go Back

+
- ) : ( - <> ); }; @@ -655,7 +648,7 @@ const AvailabilityPage = ({ profile, eventType }: Props) => { {timezoneDropdown} - + {/* Temporarily disabled - booking?.startTime && rescheduleUid && (