Skip to content

Commit 8127b6b

Browse files
authored
Merge pull request #2827 from IntersectMBO/fix/displaying-dreps-with-wrong-donotlist
fix: displaying DReps with doNotList as string
2 parents e7c813e + 6eb6a27 commit 8127b6b

File tree

6 files changed

+79
-33
lines changed

6 files changed

+79
-33
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ changes.
1616

1717
### Fixed
1818

19-
-
19+
- Fix displaying DRep with doNotList property as string
2020

2121
### Changed
2222

govtool/frontend/src/pages/DRepDirectoryContent.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from "@hooks";
1515
import { DataActionsBar, EmptyStateDrepDirectory } from "@molecules";
1616
import { AutomatedVotingOptions, DRepCard } from "@organisms";
17-
import { correctAdaFormat, isSameDRep, uniqBy } from "@utils";
17+
import { correctAdaFormat, isSameDRep, uniqBy, parseBoolean } from "@utils";
1818
import { DRepData, DRepListSort, DRepStatus } from "@models";
1919
import {
2020
AutomatedVotingOptionCurrentDelegation,
@@ -107,9 +107,15 @@ export const DRepDirectoryContent: FC<DRepDirectoryContentProps> = ({
107107
const ada = correctAdaFormat(votingPower);
108108

109109
const listedDRepsWithoutYourself = uniqBy(
110-
dRepList?.filter((dRep) => !dRep.doNotList && !isSameDRep(dRep, myDRepId)),
110+
dRepList?.filter(
111+
(dRep) =>
112+
(typeof dRep.doNotList === "string"
113+
? !parseBoolean(dRep.doNotList)
114+
: !dRep.doNotList) && !isSameDRep(dRep, myDRepId),
115+
),
111116
"view",
112117
);
118+
113119
const dRepListToDisplay =
114120
yourselfDRep && showYourselfDRep
115121
? [yourselfDRep, ...listedDRepsWithoutYourself]

govtool/frontend/src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ export * from "./testIdFromLabel";
3737
export * from "./uniqBy";
3838
export * from "./wait";
3939
export * from "./getBase64ImageDetails";
40+
export * from "./parseBoolean";
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Parses a string value and returns its boolean equivalent.
3+
*
4+
* @param value - The string value to be parsed.
5+
* @returns `true` if the value is "true" (case insensitive),
6+
* `false` if the value is "false" (case insensitive),
7+
* or `null` if the value is neither.
8+
*/
9+
export const parseBoolean = (value: string): boolean | null =>
10+
({
11+
true: true,
12+
false: false,
13+
}[String(value).toLowerCase()] ?? null);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
import { parseBoolean } from "../parseBoolean";
3+
4+
describe("parseBoolean", () => {
5+
it("should return true for 'true' (case insensitive)", () => {
6+
expect(parseBoolean("true")).toBe(true);
7+
expect(parseBoolean("TRUE")).toBe(true);
8+
expect(parseBoolean("TrUe")).toBe(true);
9+
});
10+
11+
it("should return false for 'false' (case insensitive)", () => {
12+
expect(parseBoolean("false")).toBe(false);
13+
expect(parseBoolean("FALSE")).toBe(false);
14+
expect(parseBoolean("FaLsE")).toBe(false);
15+
});
16+
17+
it("should return null for any other string", () => {
18+
expect(parseBoolean("yes")).toBeNull();
19+
expect(parseBoolean("no")).toBeNull();
20+
expect(parseBoolean("1")).toBeNull();
21+
expect(parseBoolean("0")).toBeNull();
22+
expect(parseBoolean("")).toBeNull();
23+
});
24+
25+
it("should return null for non-string values", () => {
26+
expect(parseBoolean(null as any)).toBeNull();
27+
expect(parseBoolean(undefined as any)).toBeNull();
28+
expect(parseBoolean(123 as any)).toBeNull();
29+
expect(parseBoolean({} as any)).toBeNull();
30+
});
31+
});

govtool/frontend/yarn.lock

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,15 +1367,15 @@
13671367
resolved "https://registry.npmjs.org/@emurgo/cardano-serialization-lib-asmjs/-/cardano-serialization-lib-asmjs-12.1.1.tgz"
13681368
integrity sha512-K3f28QUfLDJ7seO6MtKfMYtRm5ccf36TQ5yxyTmZqX1TA85MkriEdxqpgV9KLiLEA95emwnlvU2/WmlHMRPg1A==
13691369

1370-
"@esbuild/linux-x64@0.21.5":
1370+
"@esbuild/darwin-arm64@0.21.5":
13711371
version "0.21.5"
1372-
resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz"
1373-
integrity sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==
1372+
resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz"
1373+
integrity sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==
13741374

1375-
"@esbuild/linux-x64@0.24.2":
1375+
"@esbuild/darwin-arm64@0.24.2":
13761376
version "0.24.2"
1377-
resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.24.2.tgz"
1378-
integrity sha512-8Qi4nQcCTbLnK9WoMjdC9NiTG6/E38RNICU6sUNqK0QFxCYgoARqVqxdFmWkdonVsvGqWhmm7MO0jyTqLqwj0Q==
1377+
resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.24.2.tgz"
1378+
integrity sha512-kj3AnYWc+CekmZnS5IPu9D+HWtUI49hbnyqk0FLEJDbzCIQt7hg7ucF1SQAilhtYpIujfaHr6O0UHlzzSPdOeA==
13791379

13801380
"@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0":
13811381
version "4.4.1"
@@ -2162,15 +2162,10 @@
21622162
resolved "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz"
21632163
integrity sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==
21642164

2165-
"@parcel/watcher-linux-x64-glibc@2.5.0":
2165+
"@parcel/watcher-darwin-arm64@2.5.0":
21662166
version "2.5.0"
2167-
resolved "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.0.tgz"
2168-
integrity sha512-d9AOkusyXARkFD66S6zlGXyzx5RvY+chTP9Jp0ypSTC9d4lzyRs9ovGf/80VCxjKddcUvnsGwCHWuF2EoPgWjw==
2169-
2170-
2171-
version "2.5.0"
2172-
resolved "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.0.tgz"
2173-
integrity sha512-iqOC+GoTDoFyk/VYSFHwjHhYrk8bljW6zOhPuhi5t9ulqiYq1togGJB5e3PwYVFFfeVgc6pbz3JdQyDoBszVaA==
2167+
resolved "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.0.tgz"
2168+
integrity sha512-hyZ3TANnzGfLpRA2s/4U1kbw2ZI4qGxaRJbBH2DCSREFfubMswheh8TeiC1sGZ3z2jUf3s37P0BBlrD3sjVTUw==
21742169

21752170
"@parcel/watcher@^2.4.1":
21762171
version "2.5.0"
@@ -2283,15 +2278,10 @@
22832278
estree-walker "^2.0.2"
22842279
picomatch "^4.0.2"
22852280

2286-
"@rollup/rollup-linux-x64-gnu@4.27.4":
2281+
"@rollup/rollup-darwin-arm64@4.27.4":
22872282
version "4.27.4"
2288-
resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.27.4.tgz"
2289-
integrity sha512-Ni8mMtfo+o/G7DVtweXXV/Ol2TFf63KYjTtoZ5f078AUgJTmaIJnj4JFU7TK/9SVWTaSJGxPi5zMDgK4w+Ez7Q==
2290-
2291-
2292-
version "4.27.4"
2293-
resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.27.4.tgz"
2294-
integrity sha512-5AeeAF1PB9TUzD+3cROzFTnAJAcVUGLuR8ng0E0WXGkYhp6RD6L+6szYVX+64Rs0r72019KHZS1ka1q+zU/wUw==
2283+
resolved "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.27.4.tgz"
2284+
integrity sha512-PlNiRQapift4LNS8DPUHuDX/IdXiLjf8mc5vdEmUR0fF/pyy2qWwzdLjB+iZquGr8LuN4LnUoSEvKRwjSVYz3Q==
22952285

22962286
"@rtsao/scc@^1.1.0":
22972287
version "1.1.0"
@@ -2870,15 +2860,10 @@
28702860
"@svgr/plugin-svgo" "^5.5.0"
28712861
loader-utils "^2.0.0"
28722862

2873-
"@swc/core-linux-x64-gnu@1.9.3":
2863+
"@swc/core-darwin-arm64@1.9.3":
28742864
version "1.9.3"
2875-
resolved "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.9.3.tgz"
2876-
integrity sha512-ivXXBRDXDc9k4cdv10R21ccBmGebVOwKXT/UdH1PhxUn9m/h8erAWjz5pcELwjiMf27WokqPgaWVfaclDbgE+w==
2877-
2878-
2879-
version "1.9.3"
2880-
resolved "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.9.3.tgz"
2881-
integrity sha512-ILsGMgfnOz1HwdDz+ZgEuomIwkP1PHT6maigZxaCIuC6OPEhKE8uYna22uU63XvYcLQvZYDzpR3ms47WQPuNEg==
2865+
resolved "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.9.3.tgz"
2866+
integrity sha512-hGfl/KTic/QY4tB9DkTbNuxy5cV4IeejpPD4zo+Lzt4iLlDWIeANL4Fkg67FiVceNJboqg48CUX+APhDHO5G1w==
28822867

28832868
"@swc/core@*", "@swc/core@^1.5.22", "@swc/core@^1.7.26":
28842869
version "1.9.3"
@@ -7184,6 +7169,16 @@ fs@^0.0.1-security:
71847169
resolved "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz"
71857170
integrity sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==
71867171

7172+
fsevents@^2.3.2, fsevents@~2.3.2, fsevents@~2.3.3:
7173+
version "2.3.3"
7174+
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz"
7175+
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
7176+
7177+
7178+
version "2.3.2"
7179+
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
7180+
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
7181+
71877182
function-bind@^1.1.2:
71887183
version "1.1.2"
71897184
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz"

0 commit comments

Comments
 (0)