From 25d409fecce84fd370f15485d8b083b17a24fe5b Mon Sep 17 00:00:00 2001 From: hugolxt <87241914+hugolxt@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:07:56 +0100 Subject: [PATCH] Fix/campaign page (#22) * change wording on time component * lint --- src/components/primitives/Time.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/primitives/Time.tsx b/src/components/primitives/Time.tsx index 09042898..f4b41648 100644 --- a/src/components/primitives/Time.tsx +++ b/src/components/primitives/Time.tsx @@ -12,13 +12,12 @@ export default function Time({ timestamp, prefix }: TimeProps) { const then = moment(Number(timestamp)).fromNow(); return then - .replace("in ", (prefix && `${prefix} `) ?? "in ") - .replace("/ minute| minutes/g", "m") - .replace(/\ba\b/, "1") - .replace(/ seconds| second/g, "s") - .replace(/ hours| hour/g, "hours") - .replace(/ days| day/g, " days") - .replace(/ months| month/g, " months"); + .replace(/in\s/, prefix ? `${prefix} ` : "in ") + .replace(/\bminute(s?)\b/g, "m") + .replace(/\bsecond(s?)\b/g, "s") + .replace(/\bhour(s?)\b/g, "hours") + .replace(/\bday(s?)\b/g, "days") + .replace(/\bmonth(s?)\b/g, (match, plural) => (plural ? "months" : "month")); }, [timestamp, prefix]); return time;