From ccca226f82d29d303537aa512782df0ed1f3b66f Mon Sep 17 00:00:00 2001 From: iamsivin Date: Fri, 15 Mar 2024 12:42:43 +0530 Subject: [PATCH] chore: Review fix --- .../dashboard/helper/snoozeHelpers.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/javascript/dashboard/helper/snoozeHelpers.js b/app/javascript/dashboard/helper/snoozeHelpers.js index 0ecdf1e3c..76010b868 100644 --- a/app/javascript/dashboard/helper/snoozeHelpers.js +++ b/app/javascript/dashboard/helper/snoozeHelpers.js @@ -73,16 +73,16 @@ export const shortenSnoozeTime = snoozedUntil => { if (!snoozedUntil) { return null; } - const shortenTime = snoozedUntil - .replace(' minutes', 'm') - .replace(' minute', 'm') - .replace(' hours', 'h') - .replace(' hour', 'h') - .replace(' days', 'd') - .replace(' day', 'd') - .replace(' months', 'mo') - .replace(' month', 'mo') - .replace(' years', 'y') - .replace(' year', 'y'); + const shortenTime = snoozedUntil.replace( + /( minutes?| hours?| days?| months?| years?)/g, + (match, unitMatch) => { + if (unitMatch === ' minutes' || unitMatch === ' minute') return 'm'; + if (unitMatch === ' hours' || unitMatch === ' hour') return 'h'; + if (unitMatch === ' days' || unitMatch === ' day') return 'd'; + if (unitMatch === ' months' || unitMatch === ' month') return 'mo'; + if (unitMatch === ' years' || unitMatch === ' year') return 'y'; + return match; + } + ); return shortenTime; };