Skip to content

Commit 1663f56

Browse files
authored
Merge pull request #2396 from IntersectMBO/fix/2372--ada-quantities-format-should-avoid-thousands-when-the-total-is-0
fix(#2372): fix ada quantities format
2 parents 4ff3e14 + e27ab29 commit 1663f56

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ changes.
1818

1919
- Fix listing voted-on governance actions [Issue 2379](https://github.com/IntersectMBO/govtool/issues/2379)
2020
- Fix wronly displayed markdown on slider card [Issue 2263](https://github.com/IntersectMBO/govtool/issues/2316)
21+
- fix ada quantities format to avoid thousands when the total is 0 [Issue 2372](https://github.com/IntersectMBO/govtool/issues/2382)
2122

2223
### Changed
2324

govtool/frontend/src/utils/adaFormat.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ export const correctVoteAdaFormat = (
1414
) => {
1515
if (lovelace) {
1616
const ada = lovelace / LOVELACE;
17+
1718
return ada.toLocaleString(locale, {
18-
minimumFractionDigits: 3,
1919
maximumFractionDigits: 3,
2020
});
2121
}
22-
return "0,000";
22+
return "0";
2323
};
2424

2525
export const correctDRepDirectoryFormat = (lovelace: number | undefined) => {

govtool/frontend/src/utils/tests/adaFormat.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,19 @@ describe("correctVoteAdaFormat", () => {
6666

6767
test("Returns 0 for undefined lovelace value", () => {
6868
const lovelace = undefined;
69-
const expectedResult = "0,000";
69+
const expectedResult = "0";
7070
expect(correctVoteAdaFormat(lovelace, "en-US")).toBe(expectedResult);
7171
});
7272

7373
test("Returns 0 for zero lovelace value", () => {
7474
const lovelace = 0;
75-
const expectedResult = "0,000";
75+
const expectedResult = "0";
7676
expect(correctVoteAdaFormat(lovelace, "en-US")).toBe(expectedResult);
7777
});
7878

7979
test("Returns 0 for small lovelace value", () => {
8080
const lovelace = 123;
81-
const expectedResult = "0.000";
81+
const expectedResult = "0";
8282
expect(correctVoteAdaFormat(lovelace, "en-US")).toBe(expectedResult);
8383
});
8484
});

0 commit comments

Comments
 (0)