From 1298b05e1a056f83eee170a7cf115e5dacc064b1 Mon Sep 17 00:00:00 2001 From: Aldrin <53973174+Dhoni77@users.noreply.github.com> Date: Fri, 6 Oct 2023 15:37:55 +0530 Subject: [PATCH] fix: Single Use Private link does not regenerate after use (#11705) * feat: pass down props for hashedlink * feat: update booking mapper --------- Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> --- apps/web/pages/d/[link]/[slug].tsx | 3 +++ packages/features/bookings/Booker/Booker.tsx | 2 ++ .../Booker/components/BookEventForm/BookEventForm.tsx | 7 ++++++- packages/features/bookings/Booker/types.ts | 4 ++++ .../book-event-form/booking-to-mutation-input-mapper.tsx | 7 ++++--- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/apps/web/pages/d/[link]/[slug].tsx b/apps/web/pages/d/[link]/[slug].tsx index f70f0b6a34..73b4e91f02 100644 --- a/apps/web/pages/d/[link]/[slug].tsx +++ b/apps/web/pages/d/[link]/[slug].tsx @@ -27,6 +27,7 @@ export default function Type({ isTeamEvent, entity, duration, + hashedLink, }: PageProps) { return (
@@ -46,6 +47,7 @@ export default function Type({ isTeamEvent={isTeamEvent} entity={entity} duration={duration} + hashedLink={hashedLink} />
); @@ -149,6 +151,7 @@ async function getUserPageProps(context: GetServerSidePropsContext) { // Sending the team event from the server, because this template file // is reused for both team and user events. isTeamEvent, + hashedLink: link, }, }; } diff --git a/packages/features/bookings/Booker/Booker.tsx b/packages/features/bookings/Booker/Booker.tsx index d8995856ff..622da4cf77 100644 --- a/packages/features/bookings/Booker/Booker.tsx +++ b/packages/features/bookings/Booker/Booker.tsx @@ -44,6 +44,7 @@ const BookerComponent = ({ isTeamEvent, entity, duration, + hashedLink, }: BookerProps) => { /** * Prioritize dateSchedule load @@ -285,6 +286,7 @@ const BookerComponent = ({ setSeatedEventData({ ...seatedEventData, bookingUid: undefined, attendees: undefined }); } }} + hashedLink={hashedLink} /> diff --git a/packages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsx b/packages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsx index 7c12ff9478..60f9a627cf 100644 --- a/packages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsx +++ b/packages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsx @@ -41,11 +41,12 @@ import { FormSkeleton } from "./Skeleton"; type BookEventFormProps = { onCancel?: () => void; + hashedLink?: string | null; }; type DefaultValues = Record; -export const BookEventForm = ({ onCancel }: BookEventFormProps) => { +export const BookEventForm = ({ onCancel, hashedLink }: BookEventFormProps) => { const [slotReservationId, setSlotReservationId] = useSlotReservationId(); const reserveSlotMutation = trpc.viewer.public.slots.reserveSlot.useMutation({ trpc: { @@ -114,6 +115,7 @@ export const BookEventForm = ({ onCancel }: BookEventFormProps) => { isRescheduling={isRescheduling} eventQuery={eventQuery} rescheduleUid={rescheduleUid} + hashedLink={hashedLink} /> ); }; @@ -124,11 +126,13 @@ export const BookEventFormChild = ({ isRescheduling, eventQuery, rescheduleUid, + hashedLink, }: BookEventFormProps & { initialValues: DefaultValues; isRescheduling: boolean; eventQuery: ReturnType; rescheduleUid: string | null; + hashedLink?: string | null; }) => { const eventType = eventQuery.data; const bookingFormSchema = z @@ -332,6 +336,7 @@ export const BookEventFormChild = ({ }), {} ), + hashedLink, }; if (eventQuery.data?.recurringEvent?.freq && recurringEventCount) { diff --git a/packages/features/bookings/Booker/types.ts b/packages/features/bookings/Booker/types.ts index dbbf9ec5c4..badfe667c8 100644 --- a/packages/features/bookings/Booker/types.ts +++ b/packages/features/bookings/Booker/types.ts @@ -64,6 +64,10 @@ export interface BookerProps { * otherwise, the default value is selected */ duration?: number | null; + /** + * Refers to the private link from event types page. + */ + hashedLink?: string | null; } export type BookerState = "loading" | "selecting_date" | "selecting_time" | "booking"; diff --git a/packages/features/bookings/lib/book-event-form/booking-to-mutation-input-mapper.tsx b/packages/features/bookings/lib/book-event-form/booking-to-mutation-input-mapper.tsx index f9ca1cf538..2abed19098 100644 --- a/packages/features/bookings/lib/book-event-form/booking-to-mutation-input-mapper.tsx +++ b/packages/features/bookings/lib/book-event-form/booking-to-mutation-input-mapper.tsx @@ -18,6 +18,7 @@ type BookingOptions = { metadata?: Record; bookingUid?: string; seatReferenceUid?: string; + hashedLink?: string | null; }; export const mapBookingToMutationInput = ({ @@ -32,6 +33,7 @@ export const mapBookingToMutationInput = ({ metadata, bookingUid, seatReferenceUid, + hashedLink, }: BookingOptions): BookingCreateBody => { return { ...values, @@ -47,11 +49,10 @@ export const mapBookingToMutationInput = ({ language: language, rescheduleUid, metadata: metadata || {}, - hasHashedBookingLink: false, + hasHashedBookingLink: hashedLink ? true : false, bookingUid, seatReferenceUid, - // hasHashedBookingLink, - // hashedLink, + hashedLink, }; };