misc: updated renewal unit UI

This commit is contained in:
Sheen Capadngan
2025-05-23 02:51:09 +08:00
parent a40d4efa39
commit 12071e4816
2 changed files with 79 additions and 21 deletions
+22
View File
@@ -44,3 +44,25 @@ export const timeAgo = (inputDate: Date, currentDate: Date): string => {
elapsedMilliseconds >= 0 ? "ago" : "from now"
}`;
};
export enum TimeUnit {
DAY = "days",
WEEK = "weeks",
MONTH = "months",
YEAR = "years"
}
export const convertTimeUnitValueToDays = (unit: TimeUnit, value: number) => {
switch (unit) {
case TimeUnit.DAY:
return value;
case TimeUnit.WEEK:
return value * 7;
case TimeUnit.MONTH:
return value * 30;
case TimeUnit.YEAR:
return value * 365;
default:
throw new Error(`Unknown time unit: ${unit}`);
}
};