All files / src/features/Events/EventDetail/tickets TicketCheckInSection.tsx

100% Statements 11/11
100% Branches 10/10
100% Functions 2/2
100% Lines 8/8

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                        2x 33x   33x 33x 30x 25x 24x     33x                                                      
import {
  EventTicketRow,
  TICKET_CHECKIN_METHOD_LABELS,
  TICKET_PANEL_STATUS,
} from "./ticket.types";
import { Row, Section, usePanelDateTime } from "./EventTicketPanel.atoms";
 
type Props = {
  row?: EventTicketRow;
};
 
/** The panel's "Check-in Status" section. */
const TicketCheckInSection = ({ row }: Props) => {
  const dateTime = usePanelDateTime();
 
  const statusValue = (() => {
    if (row?.doNotAdmit) return TICKET_PANEL_STATUS.prohibited;
    if (row?.checkedInAt) return TICKET_PANEL_STATUS.checkedIn;
    if (row?.isExpired) return TICKET_PANEL_STATUS.expired;
    return TICKET_PANEL_STATUS.pending;
  })();
 
  return (
    <Section title="Check-in Status">
      <Row label="Status" value={statusValue} />
      <Row label="Date & Time" value={dateTime(row?.checkedInAt)} />
      <Row
        label="Check-in Method"
        value={
          row?.checkInMethod
            ? TICKET_CHECKIN_METHOD_LABELS[row.checkInMethod]
            : undefined
        }
      />
      {/* Host is omitted entirely when no staff member is on record — a
          manual check-in often has none (frame 7397-99399). */}
      {row?.hostName && (
        <Row
          label="Host"
          value={row.hostName}
          caption={row.hostEmail}
          testId="ticket-panel-host"
        />
      )}
    </Section>
  );
};
 
export default TicketCheckInSection;