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 | 7x 5x 5x 5x 7x 7x 2x 7x 7x 2x 2x 7x 2x 2x 7x 4x 4x 1x 3x 1x 2x 7x 7x 7x 5x 5x 2x 2x 2x 1x 3x 1x 2x 1x 1x 1x 1x | import { Stack } from "@mui/material";
import {
ArmchairIcon,
CheckCircleIcon,
CheckSquareIcon,
ProhibitIcon,
} from "@phosphor-icons/react";
import GiveButton from "@shared/Button/GiveButton";
import GiveText from "@shared/Text/GiveText";
import GiveTooltip from "@shared/Tooltip/GiveTooltip";
import GiveTruncateText from "@shared/Text/GiveTruncateText";
import { styled, useAppTheme } from "@theme/v2/Provider";
import { PLATFORM_TIMEZONE_LABEL } from "@utils/timezones";
import {
EventTicketRow,
TICKET_DO_NOT_ADMIT_LABEL,
TICKET_INVALID_TOOLTIPS,
} from "./ticket.types";
/**
* Cell renderers for the Tickets tab (frames 7397-90421 / 7397-90442):
* Ticket ID · Purchase Date · Ticket Holder · Ticket Name · Check-in Status.
*/
type FormatInTimezone = (
date: Date | string | number,
format?: string,
) => string | number | Date | null;
const formatted = (
timestamp: number | null | undefined,
formatInTimezone: FormatInTimezone,
format: string,
) => {
// A null/0 timestamp is "unset", never 1970.
Iif (!timestamp) return "";
const value = formatInTimezone(timestamp, format);
return value ? String(value) : "";
};
export const TicketIdColumn = (row: EventTicketRow) => (
<GiveTruncateText variant="bodyS" color="primary" lineClamp={1}>
{row.displayId}
</GiveTruncateText>
);
/**
* "Jul 10, 2023" over "12:21 AM ET" (platform timezone). The zone is the
* literal ET label, not a `zzz` token — date-fns-tz renders that token as the
* raw offset ("GMT-4"), which contradicts the platform's Eastern Time label
* and flips to GMT-5 for winter dates.
*/
export const PurchaseDateColumn = (
row: EventTicketRow,
formatInTimezone: FormatInTimezone,
) => (
<Stack gap="2px" minWidth={0}>
<GiveText variant="bodyS" color="primary">
{formatted(row.purchasedAt, formatInTimezone, "MMM dd, yyyy")}
</GiveText>
<GiveText variant="bodyXS" color="secondary">
{formatted(
row.purchasedAt,
formatInTimezone,
`hh:mm a '${PLATFORM_TIMEZONE_LABEL}'`,
)}
</GiveText>
</Stack>
);
export const TicketHolderColumn = (row: EventTicketRow) => (
<Stack gap="2px" minWidth={0}>
<GiveTruncateText variant="bodyS" color="primary" lineClamp={1}>
{row.holderName}
</GiveTruncateText>
<GiveTruncateText variant="bodyXS" color="secondary" lineClamp={1}>
{row.holderEmail}
</GiveTruncateText>
</Stack>
);
/** Variant name, with the seat row + label line for seated events (90442). */
export const TicketNameColumn = (row: EventTicketRow) => {
const { palette } = useAppTheme();
return (
<Stack gap="2px" minWidth={0}>
<GiveTruncateText variant="bodyS" color="primary" lineClamp={1}>
{row.ticketName}
</GiveTruncateText>
{row.seatLabel && (
<Stack direction="row" gap="4px" alignItems="center" minWidth={0}>
<ArmchairIcon
size={14}
color={palette.icon?.["icon-secondary"]}
style={{ flexShrink: 0 }}
/>
<GiveTruncateText variant="bodyXS" color="secondary" lineClamp={1}>
{row.seatLabel}
</GiveTruncateText>
</Stack>
)}
</Stack>
);
};
/**
* The whole ticket on mobile (frame 7397-90578): code, ticket name (with the seat
* line for seated events), then the holder's name and email. The desktop columns
* are hidden below `v2_sm` — this is a different layout, not a reflow.
*/
export const MobileTicketColumn = (row: EventTicketRow) => {
const { palette } = useAppTheme();
return (
<Stack gap="4px" minWidth={0}>
<GiveTruncateText variant="bodyXS" color="secondary" lineClamp={1}>
{row.displayId}
</GiveTruncateText>
<Stack direction="row" gap="4px" alignItems="center" minWidth={0}>
{row.seatLabel && (
<>
<ArmchairIcon
size={14}
color={palette.icon?.["icon-secondary"]}
style={{ flexShrink: 0 }}
/>
<GiveText variant="bodyXS" color="secondary">
{row.seatLabel}
</GiveText>
<Dot />
</>
)}
<GiveTruncateText variant="bodyXS" color="secondary" lineClamp={1}>
{row.ticketName}
</GiveTruncateText>
</Stack>
<GiveTruncateText variant="bodyS" color="primary" lineClamp={1}>
{row.holderName}
</GiveTruncateText>
<GiveTruncateText variant="bodyXS" color="secondary" lineClamp={1}>
{row.holderEmail}
</GiveTruncateText>
</Stack>
);
};
/**
* The check-in state on mobile: right-aligned text with its icon above, and no
* action — the row opens the detail panel, which is where Check In lives.
*/
export const MobileCheckinColumn = (row: EventTicketRow) => {
const { palette } = useAppTheme();
if (row.doNotAdmit) {
return (
<MobileStatus data-testid={`ticket-mobile-do-not-admit-${row.id}`}>
<ProhibitIcon size={16} color={palette.primitive?.error?.[50]} />
<GiveText
variant="bodyS"
sx={{ color: palette.primitive?.error?.[50] }}
>
{TICKET_DO_NOT_ADMIT_LABEL}
</GiveText>
</MobileStatus>
);
}
if (row.checkedInAt) {
return (
<MobileStatus data-testid={`ticket-mobile-checked-in-${row.id}`}>
<CheckCircleIcon
size={16}
weight="fill"
color={palette.primitive?.success?.[50]}
/>
<GiveText variant="bodyS" color="primary">
Checked in
</GiveText>
</MobileStatus>
);
}
return (
<MobileStatus data-testid={`ticket-mobile-pending-${row.id}`}>
<GiveText variant="bodyS" color="secondary">
{row.isExpired ? "Expired" : "Pending"}
</GiveText>
</MobileStatus>
);
};
const MobileStatus = styled(Stack)(() => ({
flexGrow: 1,
alignItems: "flex-end",
gap: "4px",
whiteSpace: "nowrap",
}));
/** The 4px separator the frame puts between the seat and the ticket name. */
const Dot = styled("span")(({ theme }) => ({
width: "4px",
height: "4px",
borderRadius: "50%",
flexShrink: 0,
backgroundColor: theme.palette.icon?.["icon-secondary"],
}));
type CheckinProps = {
row: EventTicketRow;
formatInTimezone: FormatInTimezone;
onCheckIn: (row: EventTicketRow) => void;
isCheckingIn?: boolean;
};
/**
* The states of the Check-in Status column:
* - reversed payment → red "Do not admit", with the Voided/Refunded/Chargeback
* tooltip (copy from frame 7420-209772) when the reason is known
* - checked in → green check + timestamp
* - expired → plain text; the event is over, so there is no action
* - otherwise → the "Check In" action
*/
export const CheckinStatusColumn = ({
row,
formatInTimezone,
onCheckIn,
isCheckingIn,
}: CheckinProps) => {
const { palette } = useAppTheme();
if (row.doNotAdmit) {
const label = (
<Stack
direction="row"
gap="6px"
alignItems="center"
data-testid={`ticket-do-not-admit-${row.id}`}
>
<ProhibitIcon size={16} color={palette.primitive?.error?.[50]} />
<GiveText
variant="bodyS"
sx={{ color: palette.primitive?.error?.[50] }}
>
{TICKET_DO_NOT_ADMIT_LABEL}
</GiveText>
</Stack>
);
// The server knows the ticket is invalid but not always why (a reversal that
// was itself undone). Without a reason there is nothing to explain, so the
// row renders bare rather than with an empty tooltip.
const tooltip = row.invalidReason
? TICKET_INVALID_TOOLTIPS[row.invalidReason]
: null;
if (!tooltip) return label;
return (
<GiveTooltip
heading={tooltip.heading}
title={tooltip.body}
color="default"
width="compact"
alignment="left"
>
{label}
</GiveTooltip>
);
}
if (row.checkedInAt) {
return (
<Stack gap="2px" minWidth={0} data-testid={`ticket-checked-in-${row.id}`}>
<Stack direction="row" gap="6px" alignItems="center">
<CheckCircleIcon
size={16}
weight="fill"
color={palette.primitive?.success?.[50]}
/>
<GiveText variant="bodyS" color="primary">
Checked in
</GiveText>
</Stack>
<GiveText variant="bodyXS" color="secondary">
{formatted(
row.checkedInAt,
formatInTimezone,
`MMM dd, yyyy hh:mma '${PLATFORM_TIMEZONE_LABEL}'`,
)}
</GiveText>
</Stack>
);
}
if (row.isExpired) {
return (
<GiveText
variant="bodyS"
color="secondary"
data-testid={`ticket-expired-${row.id}`}
>
Expired
</GiveText>
);
}
return (
<GiveButton
label="Check In"
variant="outline"
color="light"
size="small"
startIcon={<CheckSquareIcon size={16} />}
disabled={isCheckingIn}
data-testid={`ticket-check-in-${row.id}`}
onClick={(e) => {
// Rows open the transaction panel on click — the button must not.
e.stopPropagation();
onCheckIn(row);
}}
/>
);
};
|