This commit is contained in:
2026-04-25 12:49:58 +05:30
parent 89ad8e376e
commit 67d4c85146
3 changed files with 62 additions and 42 deletions

View File

@@ -3,17 +3,13 @@ export const getPercentage = (progressAmount: number, totalAmount: number) => {
return Math.min(100, Math.max(0, (progressAmount / totalAmount) * 100));
};
export const parseSummary = (
summary: string | undefined,
progressAmount: number,
totalAmount: number
) => {
const displaySummary = summary ?? `Rs ${progressAmount} / Rs ${totalAmount}`;
const parts = displaySummary.split("/");
const prefixAmount = parts[0]?.trim() || "";
const suffixString =
parts.length > 1 ? `/ ${parts.slice(1).join("/").trim()}` : "";
return { prefixAmount, suffixString };
export const formatCurrency = (val: number) => {
const absVal = Math.abs(val);
if (absVal >= 100000) {
return `${(val / 100000).toFixed(2)}L`;
}
if (absVal >= 1000) {
return `${(val / 1000).toFixed(2)}k`;
}
return `${val.toFixed(2)}`;
};