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>
This commit is contained in:
Aldrin 2023-10-06 15:37:55 +05:30 committed by GitHub
parent e0c27d8721
commit 1298b05e1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 4 deletions

View File

@ -27,6 +27,7 @@ export default function Type({
isTeamEvent,
entity,
duration,
hashedLink,
}: PageProps) {
return (
<main className={getBookerWrapperClasses({ isEmbed: !!isEmbed })}>
@ -46,6 +47,7 @@ export default function Type({
isTeamEvent={isTeamEvent}
entity={entity}
duration={duration}
hashedLink={hashedLink}
/>
</main>
);
@ -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,
},
};
}

View File

@ -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}
/>
</BookerSection>

View File

@ -41,11 +41,12 @@ import { FormSkeleton } from "./Skeleton";
type BookEventFormProps = {
onCancel?: () => void;
hashedLink?: string | null;
};
type DefaultValues = Record<string, unknown>;
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<typeof useEvent>;
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) {

View File

@ -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";

View File

@ -18,6 +18,7 @@ type BookingOptions = {
metadata?: Record<string, string>;
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,
};
};