export const formatCurrency = (amount:number) => { // format number wirh 2 decimal places and a thousand separator // amount is in cents const formattedAmount = (amount/100).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'); return(formattedAmount); } /** * Formats an IBAN for display with proper spacing * Format: XX12 XXXX XXXX XXXX XXXX XX * First group: 2 letters (country) + 2 digits (check) = 4 chars * Following groups: 4 characters each * Last group: can be less than 4 characters * @param iban - IBAN string without spaces * @returns Formatted IBAN with spaces */ export const formatIban = (iban: string | null | undefined): string => { if (!iban) return ""; // Remove any existing spaces const cleaned = iban.replace(/\s/g, ''); // Split into groups: first 4 chars, then groups of 4 const groups: string[] = []; for (let i = 0; i < cleaned.length; i += 4) { groups.push(cleaned.slice(i, i + 4)); } return groups.join(' '); }