From 353a837e893229940bffee64fb2cb8afe8c8cc5c Mon Sep 17 00:00:00 2001 From: Viterbo Date: Fri, 10 May 2024 20:27:51 -0300 Subject: [PATCH] unstaked period says 10 days --- src/antelope/stores/rex.ts | 4 ++++ src/antelope/stores/utils/date-utils.ts | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/antelope/stores/rex.ts b/src/antelope/stores/rex.ts index c6b6cba5f..6a46223b4 100644 --- a/src/antelope/stores/rex.ts +++ b/src/antelope/stores/rex.ts @@ -64,6 +64,10 @@ export const useRexStore = defineStore(store_name, { state.__rexData[label]?.period ?? null, // translation function only takes the key name, without the path and adds the prefix (key:string) => getAntelope().config.localizationHandler(`antelope.words.${key}`), + // force to show days instead of being dynamic, + 'days', + // force to round the number + true, ), }, diff --git a/src/antelope/stores/utils/date-utils.ts b/src/antelope/stores/utils/date-utils.ts index de5108331..50d303033 100644 --- a/src/antelope/stores/utils/date-utils.ts +++ b/src/antelope/stores/utils/date-utils.ts @@ -43,7 +43,7 @@ export function dateIsWithinXMinutes(epochMs: number, minutes: number) { * @param {function} $t translation function. Should accept a string (just the keyname without a path) and return a translated string * @returns {string} plain english time period */ -export function prettyTimePeriod(seconds: number|null, $t: (key: string) => string, round = false) { +export function prettyTimePeriod(seconds: number|null, $t: (key: string) => string, units = '', round = false) { if (seconds === null) { return '--'; } @@ -51,19 +51,19 @@ export function prettyTimePeriod(seconds: number|null, $t: (key: string) => stri let quantity; let unit; - if (seconds < HOUR_SECONDS) { + if (seconds < HOUR_SECONDS || units === 'minutes') { quantity = seconds / MINUTE_SECONDS; unit = $t('minutes'); - } else if (seconds < DAY_SECONDS) { + } else if (seconds < DAY_SECONDS || units === 'hours') { quantity = seconds / HOUR_SECONDS; unit = $t('hours'); - } else if (seconds < WEEK_SECONDS) { + } else if (seconds < WEEK_SECONDS || units === 'days') { quantity = seconds / DAY_SECONDS; unit = $t('days'); - } else if (seconds < MONTH_SECONDS) { + } else if (seconds < MONTH_SECONDS || units === 'weeks') { quantity = seconds / WEEK_SECONDS; unit = $t('weeks'); - } else if (seconds < YEAR_SECONDS) { + } else if (seconds < YEAR_SECONDS || units === 'months') { quantity = seconds / MONTH_SECONDS; unit = $t('months'); } else {