Skip to content

Commit

Permalink
Merge pull request #2319 from IntersectMBO/fix/2307-view-your-drep-de…
Browse files Browse the repository at this point in the history
…tails-link-doesnt-work

fix(#2307): fix viewing DRep details
  • Loading branch information
MSzalowski authored Nov 4, 2024
2 parents 0b189a3 + 04164b5 commit a4ef51e
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ changes.

- Fix searching by DRep Given name
- Fix displaying the wallet connected modal
- Fix navigating to DRep details [Issue 2307](https://github.com/IntersectMBO/govtool/issues/2307)

### Changed

Expand Down
1 change: 1 addition & 0 deletions govtool/backend/sql/list-dreps.sql
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ FROM
WHERE
(
COALESCE(?, '') = '' OR
(CASE WHEN LENGTH(?) % 2 = 0 AND ? ~ '^[0-9a-fA-F]+$' THEN dh.raw = decode(?, 'hex') ELSE false END) OR
dh.view ILIKE ? OR
off_chain_vote_drep_data.given_name ILIKE ?
)
Expand Down
3 changes: 3 additions & 0 deletions govtool/backend/src/VVA/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ listDReps mSearchQuery = withPool $ \conn -> do
let searchParam = fromMaybe "" mSearchQuery
results <- liftIO $ SQL.query conn listDRepsSql
( searchParam
, searchParam
, searchParam
, searchParam
, "%" <> searchParam <> "%"
, "%" <> searchParam <> "%"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ export const DRepDashboardCard = ({
),
};

const navigateToDrepDirectory = () =>
dRep &&
navigate(PATHS.dashboardDRepDirectoryDRep.replace(":dRepId", dRep.view), {
state: { enteredFromWithinApp: true },
});
const navigateToDrepDirectory = () => {
if (dRep) {
navigate(PATHS.dashboardDRepDirectoryDRep.replace(":dRepId", dRep.view), {
state: { enteredFromWithinApp: true },
});
}
};

const cardProps: Partial<DashboardActionCardProps> = (() => {
// transaction in progress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const useGetDRepDetailsQuery = (
) => {
const { dRepData, isDRepListLoading } = useGetDRepListInfiniteQuery(
{ searchPhrase: dRepId ?? undefined },
{ enabled: options?.enabled && !!dRepId },
{ enabled: options?.enabled || !!dRepId },
);

return { dRep: dRepData?.[0], isLoading: isDRepListLoading };
Expand Down
15 changes: 8 additions & 7 deletions govtool/frontend/src/pages/RegisterAsdRep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ export const RegisterAsdRep = () => {
title={t(`registration.alreadyRegistered.title`)}
description={t(`registration.alreadyRegistered.description`)}
primaryButtonText={t("registration.alreadyRegistered.viewDetails")}
onPrimaryButton={() =>
dRep &&
navigate(
PATHS.dashboardDRepDirectoryDRep.replace(":dRepId", dRep.view),
{ state: { enteredFromWithinApp: true } },
)
}
onPrimaryButton={() => {
if (dRep) {
navigate(
PATHS.dashboardDRepDirectoryDRep.replace(":dRepId", dRep.view),
{ state: { enteredFromWithinApp: true } },
);
}
}}
/>
</CenteredBoxPageWrapper>
);
Expand Down
3 changes: 1 addition & 2 deletions govtool/frontend/src/services/requests/getDRepList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ export const getDRepList = async ({
const validatedResponse = {
...response.data,
elements: await Promise.all(
response.data.elements
.map(async (drep) => mapDtoToDrep(drep)),
response.data.elements.map(async (drep) => mapDtoToDrep(drep)),
),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const GovernanceActionDetailsCardComponent: Story = {

await expect(canvas.getAllByText(/yes/i)).toHaveLength(2);
await expect(canvas.getAllByText(/abstain/i)).toHaveLength(3);
await expect(canvas.getAllByText(/no/i)).toHaveLength(2);
await expect(canvas.getAllByText(/no/i)).toHaveLength(4);
},
};

Expand Down

0 comments on commit a4ef51e

Please sign in to comment.