| 1 |
import {__} from '@wordpress/i18n'; |
| 2 |
import {getCampaignOptionsWindowData, amountFormatter} from '@givewp/campaigns/utils'; |
| 3 |
|
| 4 |
|
| 5 |
export const getGoalDescription = (goalType: string) => { |
| 6 |
switch (goalType) { |
| 7 |
case 'amount': |
| 8 |
return __('Amount raised', 'give'); |
| 9 |
case 'donations': |
| 10 |
return __('Number of donations', 'give'); |
| 11 |
case 'donors': |
| 12 |
return __('Number of donors', 'give'); |
| 13 |
case 'amountFromSubscriptions': |
| 14 |
return __('Recurring amount raised', 'give'); |
| 15 |
case 'subscriptions': |
| 16 |
return __('Number of recurring donations', 'give'); |
| 17 |
case 'donorsFromSubscriptions': |
| 18 |
return __('Number of recurring donors', 'give'); |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
export const getGoalFormattedValue = (goalType: string, value: number) => { |
| 24 |
switch (goalType) { |
| 25 |
case 'amount': |
| 26 |
case 'amountFromSubscriptions': |
| 27 |
const {currency} = getCampaignOptionsWindowData() |
| 28 |
const currencyFormatter = amountFormatter(currency); |
| 29 |
|
| 30 |
return currencyFormatter.format(value); |
| 31 |
|
| 32 |
default: |
| 33 |
return value; |
| 34 |
} |
| 35 |
} |
| 36 |
|