const IndianCurrencyFormatter = new Intl.NumberFormat(undefined, {
	style: "currency",
	currency: "INR",
});

const USDCurrencyFormatter = new Intl.NumberFormat(undefined, {
	style: "currency",
	currency: "USD",
});

const IndianCurrencyFormatterWithoutDecimal = new Intl.NumberFormat(undefined, {
	style: "currency",
	currency: "INR",
	maximumSignificantDigits: 3,
});

const USDCurrencyFormatterWithoutDecimal = new Intl.NumberFormat(undefined, {
	style: "currency",
	currency: "USD",
	maximumSignificantDigits: 3,
});

export function getFormattedCurrency(currency, value) {
	if (currency === "INR") return IndianCurrencyFormatter.format(value);
	else if (currency === "USD") return USDCurrencyFormatter.format(value);
	return value;
}

export function getFormattedCurrencyWithoutDecimals(currency, value) {
	if (currency === "INR")
		return IndianCurrencyFormatterWithoutDecimal.format(value);
	else if (currency === "USD")
		return USDCurrencyFormatterWithoutDecimal.format(value);
	return value;
}

export const capitalize = (s) => {
	if (typeof s !== "string") return s;
	return s.charAt(0).toUpperCase() + s.slice(1);
};

export const months = [
	"JANUARY",
	"FEBRUARY",
	"MARCH",
	"APRIL",
	"MAY",
	"JUNE",
	"JULY",
	"AUGUST",
	"SEPTEMBER",
	"OCTOBER",
	"NOVEMBER",
	"DECEMBER",
];
