import { useIntl } from 'react-intl' import IconChip from '../IconChip' import DiscountIcon from '../Icons/Nucleo/Benefits/discount-2-2' import FilledDiscountIcon from '../Icons/Nucleo/Benefits/FilledDiscount' import { MaterialIcon } from '../Icons/MaterialIcon' import { Typography } from '../Typography' import styles from './bookingCodeChip.module.css' import { cx } from 'class-variance-authority' import { IconButton } from '../IconButton' type BaseBookingCodeChipProps = { alignCenter?: boolean bookingCode?: string | null isCampaign?: boolean isUnavailable?: boolean isCampaignUnavailable?: boolean withText?: boolean filledIcon?: boolean } type BookingCodeChipWithoutCloseButtonProps = BaseBookingCodeChipProps & { withCloseButton?: false onClose?: undefined } type BookingCodeChipWithCloseButtonProps = BaseBookingCodeChipProps & { withCloseButton: true onClose: () => void } type BookingCodeChipProps = | BookingCodeChipWithoutCloseButtonProps | BookingCodeChipWithCloseButtonProps export function BookingCodeChip({ alignCenter, bookingCode, isCampaign, isCampaignUnavailable, isUnavailable, withText = true, filledIcon = false, withCloseButton, onClose, }: BookingCodeChipProps) { const intl = useIntl() if (isCampaign || isCampaignUnavailable) { return ( ) : ( ) } className={alignCenter ? styles.center : undefined} >

{intl.formatMessage({ id: 'booking.campaign', defaultMessage: 'Campaign', })} {bookingCode && ( {/*eslint-disable-next-line formatjs/no-literal-string-in-jsx*/} ∙ {bookingCode} )}

{withCloseButton && ( )}
) } if (!bookingCode) { return null } return ( ) : ( ) } className={alignCenter ? styles.center : undefined} >

{withText && ( {intl.formatMessage({ id: 'booking.bookingCode', defaultMessage: 'Booking code', })} )} {bookingCode}

{withCloseButton && ( )}
) }