diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f7439b6e..cc0cb0821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/govtool/backend/sql/list-dreps.sql b/govtool/backend/sql/list-dreps.sql index ea6414145..043b316d2 100644 --- a/govtool/backend/sql/list-dreps.sql +++ b/govtool/backend/sql/list-dreps.sql @@ -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 ? ) diff --git a/govtool/backend/src/VVA/DRep.hs b/govtool/backend/src/VVA/DRep.hs index 730814e4f..fd4034c12 100644 --- a/govtool/backend/src/VVA/DRep.hs +++ b/govtool/backend/src/VVA/DRep.hs @@ -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 <> "%" ) diff --git a/govtool/frontend/src/components/organisms/DashboardCards/DRepDashboardCard.tsx b/govtool/frontend/src/components/organisms/DashboardCards/DRepDashboardCard.tsx index e5c6f8e77..b9c4338f7 100644 --- a/govtool/frontend/src/components/organisms/DashboardCards/DRepDashboardCard.tsx +++ b/govtool/frontend/src/components/organisms/DashboardCards/DRepDashboardCard.tsx @@ -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 = (() => { // transaction in progress diff --git a/govtool/frontend/src/hooks/queries/useGetDrepDetailsQuery.ts b/govtool/frontend/src/hooks/queries/useGetDrepDetailsQuery.ts index ee45f3bb4..9bb53a206 100644 --- a/govtool/frontend/src/hooks/queries/useGetDrepDetailsQuery.ts +++ b/govtool/frontend/src/hooks/queries/useGetDrepDetailsQuery.ts @@ -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 }; diff --git a/govtool/frontend/src/pages/RegisterAsdRep.tsx b/govtool/frontend/src/pages/RegisterAsdRep.tsx index 2ae4d883b..8d50f42ed 100644 --- a/govtool/frontend/src/pages/RegisterAsdRep.tsx +++ b/govtool/frontend/src/pages/RegisterAsdRep.tsx @@ -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 } }, + ); + } + }} /> ); diff --git a/govtool/frontend/src/services/requests/getDRepList.ts b/govtool/frontend/src/services/requests/getDRepList.ts index 89bd84263..532f7ee60 100644 --- a/govtool/frontend/src/services/requests/getDRepList.ts +++ b/govtool/frontend/src/services/requests/getDRepList.ts @@ -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)), ), }; diff --git a/govtool/frontend/src/stories/GovernanceActionDetailsCard.stories.ts b/govtool/frontend/src/stories/GovernanceActionDetailsCard.stories.ts index e9b1b0f70..af67453a8 100644 --- a/govtool/frontend/src/stories/GovernanceActionDetailsCard.stories.ts +++ b/govtool/frontend/src/stories/GovernanceActionDetailsCard.stories.ts @@ -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); }, };