export const formatCurrency = (amount: number | undefined | null): string => {
  if (amount === undefined || amount === null || isNaN(Number(amount))) {
    return '£0.00';
  }
  return new Intl.NumberFormat('en-GB', {
    style: 'currency',
    currency: 'GBP'
  }).format(Number(amount));
};

export function formatGBP(value: number | undefined | null) {
  if (value === undefined || value === null || isNaN(Number(value))) {
    return '£0.00';
  }
  return Number(value).toLocaleString('en-GB', {
    style: 'currency',
    currency: 'GBP',
    minimumFractionDigits: 2,
    maximumFractionDigits: 2,
  });
}

export function formatNumber(value: number | undefined | null, options: Intl.NumberFormatOptions = {}) {
  if (value === undefined || value === null || isNaN(Number(value))) {
    return '0';
  }
  return Number(value).toLocaleString('en-GB', options);
}