export type CurrencyCode = 'INR' | 'USD' | 'EUR' | 'GBP';

export const currencyRates: Record<CurrencyCode, { symbol: string; rate: number; label: string }> = {
  INR: { symbol: '₹', rate: 1, label: 'INR (₹)' },
  USD: { symbol: '$', rate: 0.012, label: 'USD ($)' },
  EUR: { symbol: '€', rate: 0.011, label: 'EUR (€)' },
  GBP: { symbol: '£', rate: 0.0094, label: 'GBP (£)' },
};

export function formatPrice(amountInINR: number, currency: CurrencyCode = 'INR'): string {
  if (!amountInINR || isNaN(amountInINR)) return '₹0';
  const config = currencyRates[currency] || currencyRates.INR;
  const converted = currency === 'INR' ? Math.round(amountInINR) : Math.round((amountInINR * config.rate) * 100) / 100;
  return `${config.symbol}${converted.toLocaleString()}`;
}
