import { useTranslation } from 'react-i18next' import Price, { Currency, Locale } from './Price' import './styles.css' type PaymentItem = { title: string price: number description: string } type PaymentProps = { currency: Currency locale: Locale items: PaymentItem[] } function Payment({ currency, locale, items }: PaymentProps): JSX.Element { const { t } = useTranslation() 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 (
{t('total_today')}
{totalPrice.format()}
{items.map(toItem)}
{t('charged_only')}
) } export default Payment export { Price, Currency, Locale }