export const getCurrency = (currency: string, partnerType?: string): string => { const isFriend = partnerType && partnerType.toLowerCase() === 'friend'; return currency .replace('GBP', '£') .replace('EUR', isFriend ? '€*' : '€') .replace('CHF', isFriend ? '*CHF' : 'CHF'); }; export const formatNumber = (num: string | number) => { num = typeof num === 'string' ? parseFloat(num) : num; return num.toFixed(2).replace(/\.00$/, ''); }; export const getAmountWithCurrency = ( amount?: number | string, currency?: string | string, partnerType?: string, ): string => { if (!amount || !currency) { return null; } amount = formatNumber(amount); const currencySymbol = getCurrency(currency, partnerType); return currency === 'CHF' ? currencySymbol + ' ' + amount : currency === 'EUR' ? amount + ' ' + currencySymbol : currency === 'GBP' ? currencySymbol + amount : amount + ' ' + currency; }; export const getReduction = ( originalPrice: number, price: number, currency: string, ): string => { return getAmountWithCurrency(originalPrice - price, currency); };