Skip to content

Commit 04164b5

Browse files
committed
fix(#2307): fix viewing DRep details
1 parent 0b189a3 commit 04164b5

File tree

8 files changed

+23
-16
lines changed

8 files changed

+23
-16
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 searching by DRep Given name
2020
- Fix displaying the wallet connected modal
21+
- Fix navigating to DRep details [Issue 2307](https://github.com/IntersectMBO/govtool/issues/2307)
2122

2223
### Changed
2324

govtool/backend/sql/list-dreps.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ FROM
137137
WHERE
138138
(
139139
COALESCE(?, '') = '' OR
140+
(CASE WHEN LENGTH(?) % 2 = 0 AND ? ~ '^[0-9a-fA-F]+$' THEN dh.raw = decode(?, 'hex') ELSE false END) OR
140141
dh.view ILIKE ? OR
141142
off_chain_vote_drep_data.given_name ILIKE ?
142143
)

govtool/backend/src/VVA/DRep.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ listDReps mSearchQuery = withPool $ \conn -> do
4545
let searchParam = fromMaybe "" mSearchQuery
4646
results <- liftIO $ SQL.query conn listDRepsSql
4747
( searchParam
48+
, searchParam
49+
, searchParam
50+
, searchParam
4851
, "%" <> searchParam <> "%"
4952
, "%" <> searchParam <> "%"
5053
)

govtool/frontend/src/components/organisms/DashboardCards/DRepDashboardCard.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ export const DRepDashboardCard = ({
4343
),
4444
};
4545

46-
const navigateToDrepDirectory = () =>
47-
dRep &&
48-
navigate(PATHS.dashboardDRepDirectoryDRep.replace(":dRepId", dRep.view), {
49-
state: { enteredFromWithinApp: true },
50-
});
46+
const navigateToDrepDirectory = () => {
47+
if (dRep) {
48+
navigate(PATHS.dashboardDRepDirectoryDRep.replace(":dRepId", dRep.view), {
49+
state: { enteredFromWithinApp: true },
50+
});
51+
}
52+
};
5153

5254
const cardProps: Partial<DashboardActionCardProps> = (() => {
5355
// transaction in progress

govtool/frontend/src/hooks/queries/useGetDrepDetailsQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const useGetDRepDetailsQuery = (
66
) => {
77
const { dRepData, isDRepListLoading } = useGetDRepListInfiniteQuery(
88
{ searchPhrase: dRepId ?? undefined },
9-
{ enabled: options?.enabled && !!dRepId },
9+
{ enabled: options?.enabled || !!dRepId },
1010
);
1111

1212
return { dRep: dRepData?.[0], isLoading: isDRepListLoading };

govtool/frontend/src/pages/RegisterAsdRep.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,14 @@ export const RegisterAsdRep = () => {
7979
title={t(`registration.alreadyRegistered.title`)}
8080
description={t(`registration.alreadyRegistered.description`)}
8181
primaryButtonText={t("registration.alreadyRegistered.viewDetails")}
82-
onPrimaryButton={() =>
83-
dRep &&
84-
navigate(
85-
PATHS.dashboardDRepDirectoryDRep.replace(":dRepId", dRep.view),
86-
{ state: { enteredFromWithinApp: true } },
87-
)
88-
}
82+
onPrimaryButton={() => {
83+
if (dRep) {
84+
navigate(
85+
PATHS.dashboardDRepDirectoryDRep.replace(":dRepId", dRep.view),
86+
{ state: { enteredFromWithinApp: true } },
87+
);
88+
}
89+
}}
8990
/>
9091
</CenteredBoxPageWrapper>
9192
);

govtool/frontend/src/services/requests/getDRepList.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ export const getDRepList = async ({
5151
const validatedResponse = {
5252
...response.data,
5353
elements: await Promise.all(
54-
response.data.elements
55-
.map(async (drep) => mapDtoToDrep(drep)),
54+
response.data.elements.map(async (drep) => mapDtoToDrep(drep)),
5655
),
5756
};
5857

govtool/frontend/src/stories/GovernanceActionDetailsCard.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const GovernanceActionDetailsCardComponent: Story = {
108108

109109
await expect(canvas.getAllByText(/yes/i)).toHaveLength(2);
110110
await expect(canvas.getAllByText(/abstain/i)).toHaveLength(3);
111-
await expect(canvas.getAllByText(/no/i)).toHaveLength(2);
111+
await expect(canvas.getAllByText(/no/i)).toHaveLength(4);
112112
},
113113
};
114114

0 commit comments

Comments
 (0)