import { useTranslations } from "@/hooks/translations"; import Price, { Currency, Locale } from "./Price"; import styles from "./styles.module.css"; import Countdown from "../Countdown"; type PaymentItem = { title: string; price: number; description: string; }; type PaymentTableProps = { currency: Currency; locale: Locale; items: PaymentItem[]; }; function PaymentTable({ currency, locale, items, }: PaymentTableProps): JSX.Element { const { translate } = useTranslations(); const total = items.reduce((acc, item) => acc + item.price, 0); const totalPrice = new Price(total, currency, locale); const toItem = (item: (typeof items)[0], idx: number) => { const price = new Price(item.price, currency, locale); return (
{item.title}
{price.format()}

{item.description}

{/*

One dollar thirty six cents per day

*/}
); }; return (
{translate("total_today")}
{totalPrice.format()}
{items.map(toItem)}
{translate("charged_only", { price: totalPrice.format() })}
); } export default PaymentTable; export { Price, Currency, Locale };