Skip to content

Commit

Permalink
SOV-3464: proposal timer format (#708)
Browse files Browse the repository at this point in the history
* fix: proposal timer foramt

* chore: add changeset

* fix: timer formating issue

---------

Co-authored-by: soulBit <[email protected]>
  • Loading branch information
rick23p and soulBit authored Dec 19, 2023
1 parent f605ea9 commit 6705fa2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/rotten-ties-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend": patch
---

SOV-3464: Proposals - fix timer formatting
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,25 @@ export const VoteTimer: FC<VoteTimerProps> = ({ proposal, className }) => {
return t(pageTranslations.voteEnded);
}

return `${[days, hours, minutes, seconds].join(':')} (${
proposal.endBlock - blockNumber
}) ${t(pageTranslations.blocks)}`;
const timeArray = [days, hours, minutes, seconds];

if (!days) {
timeArray.shift();
}

if (!hours) {
timeArray.shift();
}

if (!minutes) {
timeArray.shift();
}

return `${timeArray
.map(time => String(time).padStart(2, '0'))
.join(':')} (${proposal.endBlock - blockNumber}) ${t(
pageTranslations.blocks,
)}`;
}, [blockNumber, days, hours, minutes, proposal.endBlock, seconds, status]);

return (
Expand Down

0 comments on commit 6705fa2

Please sign in to comment.