import { Currency, Locale, Price } from "../PaymentTable"; import styles from "./styles.module.css"; export interface IEmailItemProps { email: string; price: number; className?: string; } const currency = Currency.USD; const locale = Locale.EN; const roundToWhole = (value: string | number): number => { value = Number(value); if (value % Math.floor(value) !== 0) { return value; } return Math.floor(value); }; const formatEmail = (email: string): string => { return `${email.slice(0, 4)}****`; }; function EmailItem({ email, price, className = "", }: IEmailItemProps): JSX.Element { const _price = new Price(roundToWhole(price), currency, locale); return ( {formatEmail(email)} chose {_price.format()} ); } export default EmailItem;