@proca/widget
Version:
Proca is an open-source campaign toolkit designed to empower activists and organisations in their digital advocacy efforts. It provides a flexible and customisable platform for creating and managing online petitions, email campaigns, and other forms of di
19 lines (15 loc) • 522 B
JavaScript
import { useCampaignConfig } from "./useConfig";
const useFormatMoney = () => {
const campaignConfig = useCampaignConfig();
const donateConfig = campaignConfig.component.donation;
return amount => {
const maxDigit = Math.round(amount) === amount ? 0 : 2;
return Number(amount).toLocaleString(campaignConfig.lang, {
style: "currency",
maximumFractionDigits: maxDigit,
currency: donateConfig.currency.code,
// currencyDisplay: "code",
});
};
};
export { useFormatMoney };