| 1 |
import {createInterpolateElement} from '@wordpress/element'; |
| 2 |
import {__} from '@wordpress/i18n'; |
| 3 |
import {subscriptionPeriod, SubscriptionPeriod} from "../registrars/templates/groups/DonationAmount/subscriptionPeriod"; |
| 4 |
|
| 5 |
/** |
| 6 |
* Returns the donor-facing message for a fixed amount donation. |
| 7 |
* |
| 8 |
* @since 3.0.0 |
| 9 |
*/ |
| 10 |
export function OneTimeAmountMessage({amount}: {amount: string}) { |
| 11 |
return createInterpolateElement(__('This donation is <amount/>', 'give'), { |
| 12 |
amount: <strong>{amount}</strong>, |
| 13 |
}); |
| 14 |
} |
| 15 |
|
| 16 |
/** |
| 17 |
* Returns the donor-facing message for a recurring donation. |
| 18 |
* |
| 19 |
* @since 3.0.0 |
| 20 |
*/ |
| 21 |
export function RecurringAmountMessage({ |
| 22 |
isFixedAmount, |
| 23 |
fixedAmount, |
| 24 |
period, |
| 25 |
frequency, |
| 26 |
installments, |
| 27 |
}: { |
| 28 |
isFixedAmount: boolean; |
| 29 |
fixedAmount: string; |
| 30 |
period: subscriptionPeriod; |
| 31 |
frequency: number; |
| 32 |
installments: number; |
| 33 |
}) { |
| 34 |
const subscriptionPeriod = new SubscriptionPeriod(period); |
| 35 |
|
| 36 |
const translatableString = !installments |
| 37 |
? __('This donation <amount /> every <period />.', 'give') |
| 38 |
: __('This donation <amount /> every <period /> for <count /> <donations />.', 'give'); |
| 39 |
|
| 40 |
return createInterpolateElement(translatableString, { |
| 41 |
amount: isFixedAmount ? ( |
| 42 |
<span> |
| 43 |
{__('is', 'give')} <strong>{fixedAmount}</strong> |
| 44 |
</span> |
| 45 |
) : ( |
| 46 |
<span>{__('repeats', 'give')}</span> |
| 47 |
), |
| 48 |
period: <strong>{subscriptionPeriod.label().get(frequency)}</strong>, |
| 49 |
count: <strong>{installments}</strong>, |
| 50 |
donations: <strong>{__('donations', 'give')}</strong>, |
| 51 |
}); |
| 52 |
} |
| 53 |
|