import { paypalConfig } from 'shared/config/paypal.mjs' import { useState } from 'react' import { useTranslation } from 'next-i18next' export const ns = ['patrons'] const PaypalFormBody = ({ amount, period, currency, language }) => ( <> {[ ...Object.entries(paypalConfig.vars[period === 'x' ? 'donate' : 'subscribe']), ...Object.entries(paypalConfig.vars.shared), ].map(([name, value]) => ( ))} {period === 'x' ? ( <> > ) : ( <> > )} > ) export const Subscribe = ({ color = 'secondary', subscribeOnly, amountPreset = '25', periodPreset = 'm', }) => { const { t, i18n } = useTranslation(ns) const { language } = i18n const [amount, setAmount] = useState(amountPreset) const [currency, setCurrency] = useState('eur') const [period, setPeriod] = useState(periodPreset) const { amounts, currencies } = paypalConfig const periods = subscribeOnly ? paypalConfig.periods.filter((p) => p !== 'x') : paypalConfig.periods return (