refactored ProgressCard to component
This commit is contained in:
19
src/components/ProgressCard/ProgressCard.utils.ts
Normal file
19
src/components/ProgressCard/ProgressCard.utils.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
export const getPercentage = (progressAmount: number, totalAmount: number) => {
|
||||
if (!totalAmount) return 0;
|
||||
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 };
|
||||
};
|
||||
Reference in New Issue
Block a user