Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | 13x 567x 23x 23x 5x 5x 4x 3x | import type {
ProductItemType,
SeatingRow,
TakenSeat,
} from "@sections/PayBuilder/types";
type PublicSeating = {
assignSeating?: boolean;
rows?: SeatingRow[];
takenSeats?: TakenSeat[];
};
type DeepLinkArgs = {
isPublic: boolean;
isFetched: boolean;
items?: ProductItemType[];
search: string;
isEvent: boolean;
eventProductId?: number;
isSeatingLoading: boolean;
seating?: PublicSeating;
};
export type ResolvedDeepLink = {
product: ProductItemType;
assignSeating: boolean;
seatingRows: SeatingRow[];
takenSeats: TakenSeat[];
};
// AC008/AC009 — resolve a `?sharedProductId=` deep link into the seat-aware modal
// payload. For an assigned-seating event we must WAIT until the public seating
// config has settled (isSeatingLoading), otherwise the modal opens seatless and an
// add-to-cart submits without seats. Returns null when nothing should open yet.
export const resolveSharedProductDeepLink = ({
isPublic,
isFetched,
items,
search,
isEvent,
eventProductId,
isSeatingLoading,
seating,
}: DeepLinkArgs): ResolvedDeepLink | null => {
if (!(isPublic && isFetched && items && items.length > 0)) return null;
const idParam = Number(new URLSearchParams(search).get("sharedProductId"));
if (!idParam) return null;
// Wait for the seating config to settle before opening for a seated event.
if (isEvent && eventProductId && isSeatingLoading) return null;
const product = items.find((item) => item.variantID === idParam);
if (!product) return null;
return {
product,
assignSeating: seating?.assignSeating ?? false,
seatingRows: seating?.rows ?? [],
takenSeats: seating?.takenSeats ?? [],
};
};
|