import { convertToShorthand } from '@/utills/helper';
import React from 'react';

const FormattedAmount = ({ amount, lineBreak }: { amount: string | number | null | undefined, lineBreak?: boolean }) => {
  // Ensure amount is a number, default to 0 if undefined, null, or empty string
  const amountValue = typeof amount === 'string' ? parseFloat(amount) : (typeof amount === 'number' ? amount : 0);

  const formattedAmount = Intl.NumberFormat('en-IN', {
    style: 'decimal',

  }).format(parseFloat(amountValue?.toFixed(2)));

  return <span className="formatted-amount"><span>&#8377;{formattedAmount}</span> {lineBreak === true && <br/>} <span>({convertToShorthand(amountValue)})</span></span>;
};

export default FormattedAmount;

export const FormattedBudget = ({ minAmount, maxAmount }: { minAmount: number, maxAmount : number }) => {

  return <span className="formatted-amount">
    <span>&#8377;{convertToShorthand(minAmount)} - &#8377;{convertToShorthand(maxAmount)} </span></span>;
};

