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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | 4x 65x 65x 65x 65x 65x 65x 65x 11x 11x 11x 11x 65x 65x 65x 65x 65x 12x 11x 11x 11x 65x 4x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 79x 65x 32x 65x 17x 65x 65x 192x 192x 192x 65x 65x 65x 65x 65x 65x 65x 55x 55x 55x | import { useCallback, useMemo, useState } from "react";
import { useParams, useSearchParams } from "react-router-dom";
import { ConnectionErrorState } from "@common/EmptyState";
import { useBreadcrumbs } from "@components/CustomBreadcrumbsPage/hooks/useBreadcrumbs";
import {
QKEY_EVENT_HOSTS,
QKEY_EVENT_REVIEWS,
QKEY_EVENT_TICKETS,
QKEY_EVENT_TRANSACTIONS,
} from "@constants/queryKeys";
import { Box } from "@mui/material";
import BackgroundAnimation from "@shared/Banner/BackgroundAnimation";
import { FilterPagesEnum } from "@shared/GiveFilter/constants";
import { useFilterButton } from "@shared/GiveFilter/hooks/useFilterButton";
import GiveMotionWrapper from "@shared/Motion/GiveMotionWrapper";
import GiveTruncateText from "@shared/Text/GiveTruncateText";
import { PortalRootContainerV2 } from "components/Layout/LayoutV2";
import Table from "componentsV2/Table/Table";
import { useTable } from "componentsV2/Table/hooks/useTable";
import useTableSearch from "componentsV2/Table/hooks/useTableSearch";
import { useGetEventById } from "@hooks/merchant-api/events/useGetEventById";
import { TRANSACTION_INFO_MODAL } from "modals/modal_names";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import { styled } from "@theme/v2/Provider";
import EventBreadcrumb from "./EventBreadcrumb";
import EventCompactBanner from "./EventCompactBanner";
import EventDetailHead from "./EventDetailHead";
import TabErrorState from "./TabErrorState";
import {
EVENT_BANNER_ANIMATION_PAGE,
EVENT_DETAIL_REVIEW_PARAM,
EVENT_DETAIL_TAB_PARAM,
EVENT_DETAIL_TABS,
EventDetailTab,
parseEventDetailTab,
STORED_EVENT_TRANSACTIONS_ROWS_PER_PAGE,
} from "./constants";
import { useEventTransactionColumns } from "./hooks/useEventTransactionColumns";
import { useEventTransactions } from "./hooks/useEventTransactions";
import EventTicketsTab from "./tickets/EventTicketsTab";
import EventHostTab from "./host/EventHostTab";
import EventInventoryTab from "./inventory/EventInventoryTab";
import EventReviewsTab from "./reviews/EventReviewsTab";
import { useGetFeatureFlagValues } from "FeatureFlags/useGetFeatureFlagValues";
/**
* PayBuilder 032-b — the redesigned Event Detail view.
*
* Transactions is the default tab (AC006.1). Both tabs share the same header,
* so the (…) menu is available from either one (AC001.1).
*/
const EventDetailPage = () => {
const { id } = useParams();
const { isMobileView, isLargeView } = useCustomThemeV2();
const { isEventReviewsEnabled, isFeatureFlagLoading } =
useGetFeatureFlagValues();
// The active tab lives in the query string (PayBuilder 034): the side panel's
// Reply / View all have to land on the Reviews tab, which component state
// cannot express. Everything else about the tabs is unchanged — each still
// keeps its own search, sort and pagination state.
const [searchParams, setSearchParams] = useSearchParams();
// Flags that have not resolved are unknown, not off: reading them as off here
// would render Transactions over a `?tab=reviews` link — firing its query —
// and then swap the tab out from under the merchant once Flagsmith answered.
// Held open instead, and the Reviews tab's own reads stay gated on the
// resolved flag, so nothing reaches the network before the answer arrives.
const allowReviewsTab = isEventReviewsEnabled || isFeatureFlagLoading;
const tab = parseEventDetailTab(
searchParams.get(EVENT_DETAIL_TAB_PARAM),
allowReviewsTab,
);
const setTab = useCallback(
(value: EventDetailTab) => {
const next = new URLSearchParams(searchParams);
next.set(EVENT_DETAIL_TAB_PARAM, value);
// The deep-linked review belongs to the arrival, not to the tab the
// merchant moves to next.
next.delete(EVENT_DETAIL_REVIEW_PARAM);
// Replace rather than push: switching tabs should not make Back walk
// through every tab the merchant looked at.
setSearchParams(next, { replace: true });
},
[searchParams, setSearchParams],
);
const focusReviewId =
Number(searchParams.get(EVENT_DETAIL_REVIEW_PARAM)) || undefined;
const [isScrolled, setIsScrolled] = useState(false);
const [isCompactRevealed, setIsCompactRevealed] = useState(false);
// The two tabs the collapsed header is drawn on (frames 8122-61108 /
// 8122-61150). Inventory has no table (so no caption to measure and no
// toolbar to keep reachable) and Host's nested-table head hides its column
// labels, so neither takes one.
const hasCompactBanner =
tab === EVENT_DETAIL_TABS.TRANSACTIONS || tab === EVENT_DETAIL_TABS.TICKETS;
// Each tab owns its own scroller, and the one being switched to mounts at the
// top without firing a scroll event — so the flags driven by scrolling have to
// be cleared here or the new tab starts out with the previous tab's header
// state (frosted trail, or a collapsed header over an unscrolled list).
const handleTabChange = useCallback(
(value: string) => {
// `GiveTabs` fires for the active pill too, and clearing the flags then
// would unfrost the breadcrumb over a list that is still scrolled.
if (value === tab) return;
setTab(value as EventDetailTab);
setIsScrolled(false);
setIsCompactRevealed(false);
},
// `setTab` writes the query string now, so it is not the stable setter it
// was when this only held component state.
[tab, setTab],
);
const handleTableScroll = useCallback((e: React.UIEvent<HTMLDivElement>) => {
setIsScrolled(e.currentTarget.scrollTop > 0);
}, []);
const {
product: event,
error,
isLoading: isEventLoading,
} = useGetEventById(id as string);
const { columns } = useEventTransactionColumns();
useBreadcrumbs({
product_id: event?.id,
imgSrc: event?.imageURL,
title: event?.name,
});
const {
allRows,
totalRows,
rowsPerPage,
page,
setPage,
setPageDispatcher,
isLoading,
isFetching,
isError,
} = useEventTransactions(id);
// Only the page sees both halves of the transactions empty state: the filter
// count and whether the list came back empty. Without it a filter that
// matched nothing fell through to the plain "No transactions", with no hint
// that the filter — not the event — was why (frame 8238-62023).
const {
filtersAmount: transactionFiltersAmount,
handleResetFilters: handleResetTransactionFilters,
} = useFilterButton({
filterPage: FilterPagesEnum.EVENT_TRANSACTIONS,
productId: id,
});
// Each tab keeps its own search state; the head's box is wired to whichever
// tab is active.
const transactionsSearch = useTableSearch({
queryKey: QKEY_EVENT_TRANSACTIONS,
});
const ticketsSearch = useTableSearch({ queryKey: QKEY_EVENT_TICKETS });
const hostSearch = useTableSearch({ queryKey: QKEY_EVENT_HOSTS });
const reviewsSearch = useTableSearch({ queryKey: QKEY_EVENT_REVIEWS });
const searchByTab = {
[EVENT_DETAIL_TABS.TRANSACTIONS]: transactionsSearch,
[EVENT_DETAIL_TABS.TICKETS]: ticketsSearch,
[EVENT_DETAIL_TABS.HOST]: hostSearch,
// Inventory has no search box in any of its frames, so it borrows the
// transactions state purely to satisfy the head's props. Reviews does have
// one, but it lives inside the tab (aligned to the list column, and sticky)
// rather than in the shared head — so it keeps its own state and the head
// is still rendered without its toolbar.
[EVENT_DETAIL_TABS.INVENTORY]: transactionsSearch,
[EVENT_DETAIL_TABS.REVIEWS]: transactionsSearch,
};
const activeSearch = searchByTab[tab];
const { searchQuery, handleSearchChange } = transactionsSearch;
const { setSelectedRowIdx, loadMore, numberOfPages, selectedRowIdx } =
useTable({
allRows,
isLoading,
isFetching,
totalRows,
page,
setPage,
setPageDispatcher,
openModal: TRANSACTION_INFO_MODAL,
useIdForRows: true,
storageKey: STORED_EVENT_TRANSACTIONS_ROWS_PER_PAGE,
});
// A render function rather than a node: the Tickets tab owns the list state, so
// only it can tell whether the toolbar should be there at all (frame
// 7397-90358 draws the empty state with no search / Export row).
const renderHead = useCallback(
(options?: { hideToolbar?: boolean }) => (
<EventDetailHead
event={event}
eventId={id}
tab={tab}
onTabChange={handleTabChange}
showReviewsTab={allowReviewsTab}
search={activeSearch.search}
onSearchChange={activeSearch.handleSearchChange}
hideToolbar={options?.hideToolbar}
/>
),
[
event,
id,
tab,
handleTabChange,
allowReviewsTab,
activeSearch.search,
activeSearch.handleSearchChange,
],
);
// The collapsed header that replaces the banner on scroll — see
// EventCompactBanner. Only built for the tabs that draw one; `Table` ignores
// an undefined `CompactHead` and keeps its plain pinned column header.
const compactHead = useMemo(
() =>
hasCompactBanner ? (
<EventCompactBanner
event={event}
eventId={id}
tab={tab}
search={activeSearch.search}
onSearchChange={activeSearch.handleSearchChange}
/>
) : undefined,
[
hasCompactBanner,
event,
id,
tab,
activeSearch.search,
activeSearch.handleSearchChange,
],
);
// Phones move the event name out of the collapsed row and into the top bar's
// own row, beside the menu button (frame 8091-56253) — `Table` publishes this
// up there and it takes the balance's place while scrolled. Undefined until
// there is a name: the top bar gates on the node's presence, and an element
// wrapping nothing would trade the balance for a blank slot while the event
// loads.
const compactTitle = useMemo(
() =>
event?.name ? (
<GiveTruncateText
variant="bodyS"
color="primary"
lineClamp={1}
data-testid="event-compact-nav-title"
>
{event.name}
</GiveTruncateText>
) : undefined,
[event?.name],
);
// Only the event itself failing blanks the page — there is nothing to draw
// without it. A LIST failing is scoped to its own tab below: swapping the
// whole page for the error unmounted the header and tabs, so a
// transaction-items failure made the (independent) Tickets tab unreachable.
Iif (error && !isEventLoading) return <ConnectionErrorState />;
// Both tabs render V2 tables which supply their own gutters; this padding is
// only for the sticky breadcrumb overlay, which sits outside them.
const getPagePadding = () => {
Iif (isMobileView) return "0px 20px";
Iif (isLargeView) return "0px 64px";
return "0px 40px";
};
const hostContent = (
<EventHostTab
eventId={id}
renderHead={renderHead}
onScroll={handleTableScroll}
searchQuery={hostSearch.searchQuery}
handleSearchChange={hostSearch.handleSearchChange}
/>
);
const ticketsContent = (
<EventTicketsTab
eventId={id}
renderHead={renderHead}
onScroll={handleTableScroll}
searchQuery={ticketsSearch.searchQuery}
handleSearchChange={ticketsSearch.handleSearchChange}
// Frame 7594-66313: the fulfilment column belongs to events that offer
// printed tickets and to no others. The field name is the API contract —
// `product.ProductMinimalView.printedMaterialsEnabled`, the same one
// PayBuilder round-trips.
showPickupColumn={Boolean(event?.printedMaterialsEnabled)}
compactHead={compactHead}
compactTitle={compactTitle}
onCompactVisibleChange={setIsCompactRevealed}
tablePadding={getPagePadding()}
/>
);
// The transactions error only matters while its tab is the visible one — a
// background tab's failure must not replace what the user is looking at.
const transactionsContent =
isError && !isLoading ? (
<TabErrorState head={renderHead({ hideToolbar: true })} />
) : (
<Table
type="transactions"
sectionName="Transactions"
allRows={allRows}
totalRows={totalRows}
rowsPerPage={rowsPerPage}
isLoading={isLoading || isEventLoading}
isFetching={isFetching}
page={page}
setPage={setPage}
setPageDispatcher={setPageDispatcher}
columns={columns}
openModal={TRANSACTION_INFO_MODAL}
queryKey={QKEY_EVENT_TRANSACTIONS}
sortReduxKey={QKEY_EVENT_TRANSACTIONS}
defaultSortKey="createdAt"
storageKey={STORED_EVENT_TRANSACTIONS_ROWS_PER_PAGE}
searchQuery={searchQuery}
handleSearchChange={handleSearchChange}
hasFilters={transactionFiltersAmount > 0}
handleResetFilters={handleResetTransactionFilters}
selectedRowIdx={selectedRowIdx}
setSelectedRowIdx={setSelectedRowIdx}
loadMore={loadMore}
numberOfPages={numberOfPages}
Head={renderHead()}
onScroll={handleTableScroll}
// The content sits on the page's animated backdrop, so the column
// header scrolls off with it, transparent — a pinned white header
// reads as a band cut into the backdrop.
scrollingHeader
CompactHead={compactHead}
compactTitle={compactTitle}
onCompactVisibleChange={setIsCompactRevealed}
compactAnimationPage={EVENT_BANNER_ANIMATION_PAGE}
// Matched to the gutters GiveTable computes for itself, so the collapsed
// header's column labels line up with the table's columns in every band
// (its own default is the 64px large-view value at every width).
tablePadding={getPagePadding()}
/>
);
const inventoryContent = (
<EventInventoryTab
eventId={id}
renderHead={renderHead}
onScroll={handleTableScroll}
/>
);
const reviewsContent = (
<EventReviewsTab
eventId={id}
renderHead={renderHead}
onScroll={handleTableScroll}
searchQuery={reviewsSearch.searchQuery}
handleSearchChange={reviewsSearch.handleSearchChange}
focusReviewId={focusReviewId}
/>
);
const content = {
[EVENT_DETAIL_TABS.TRANSACTIONS]: transactionsContent,
[EVENT_DETAIL_TABS.INVENTORY]: inventoryContent,
[EVENT_DETAIL_TABS.TICKETS]: ticketsContent,
[EVENT_DETAIL_TABS.HOST]: hostContent,
// parseEventDetailTab never returns REVIEWS with the flag off, so this
// entry is unreachable rather than merely unrendered.
[EVENT_DETAIL_TABS.REVIEWS]: reviewsContent,
}[tab];
return (
<PortalRootContainerV2
data-testid="event-detail-page"
// Replaces the wrapper's internal sx (this component spreads incoming
// props AFTER its own sx, so passing sx overrides it wholesale). The
// internal rule only offsets content below the fixed MobileNavBar under
// 600px, while this page's mobile layout starts at v2_sm (768px) — in the
// 600–768 band the opaque nav covered the top of the banner, swallowing
// the breadcrumb. Instead: zero padding on mobile so the backdrop runs
// behind the nav from y0 (as in the mockup), and let the head clear the
// nav itself (see BreadcrumbRow).
sx={(theme) => ({
position: "relative",
[theme.breakpoints.down("v2_sm")]: {
paddingTop: 0,
},
})}
>
{/* The animated banner backdrop every V2 portal page sits on; without it
the header renders on bare white. Events use the same animation as the
Events list (`ProductList`). */}
<BackgroundAnimation page={EVENT_BANNER_ANIMATION_PAGE} />
{/* Desktop breadcrumb, pinned over the table. The page itself doesn't
scroll on the Transactions tab (the table's internal scroller does),
so an absolutely-positioned bar behaves as sticky — the same trick the
table's CompactScrollHeader uses. Transparent while at the top, frosted
once the content scrolls beneath it. */}
<BreadcrumbOverlay
data-testid="event-breadcrumb-overlay"
className={[
isScrolled ? "breadcrumb-overlay--scrolled" : "",
// Frames 8122-61108 / 8122-61150 put the collapsed header at the very
// top of the viewport with no trail above it, and this overlay sits
// above it in the stack — so it yields once that header descends.
isCompactRevealed ? "breadcrumb-overlay--yielded" : "",
]
.filter(Boolean)
.join(" ")}
>
<BreadcrumbOverlayInner sx={{ padding: getPagePadding() }}>
<EventBreadcrumb name={event?.name} />
</BreadcrumbOverlayInner>
</BreadcrumbOverlay>
<GiveMotionWrapper
delay={30}
containerProps={{ sx: { height: "100%", zIndex: 2 } }}
customStyle={{
height: "100%",
display: "flex",
justifyContent: "center",
}}
>
{content}
</GiveMotionWrapper>
</PortalRootContainerV2>
);
};
export default EventDetailPage;
// Pinned over the table's scroller: 40px tall to match the banner frame's
// breadcrumb strip (y0–40), above the table's zIndex 100 container. Mobile
// keeps the in-flow breadcrumb inside the banner instead.
const BreadcrumbOverlay = styled(Box)(({ theme }) => ({
position: "absolute",
top: 0,
left: 0,
right: 0,
height: "40px",
zIndex: 105,
display: "flex",
alignItems: "center",
transition:
"background-color 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease",
"&.breadcrumb-overlay--yielded": {
opacity: 0,
pointerEvents: "none",
},
"&.breadcrumb-overlay--scrolled": {
backgroundColor: theme.palette.surface?.["primary-transparent"],
backdropFilter: "blur(8px)",
borderBottom: `1px solid ${theme.palette.border?.primary}`,
},
[theme.breakpoints.down("v2_sm")]: {
display: "none",
},
}));
const BreadcrumbOverlayInner = styled(Box)(() => ({
width: "100%",
maxWidth: "1920px",
margin: "0 auto",
minWidth: 0,
overflow: "hidden",
"& .MuiBreadcrumbs-ol": { flexWrap: "nowrap" },
"& .MuiBreadcrumbs-li": {
minWidth: 0,
"& > *": {
display: "block",
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
},
},
}));
|