Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
- Add workflow to automatically update any of the @intersect.mbo package [Issue 2968](https://github.com/IntersectMBO/govtool/issues/2968)
- Add Propose Governance Action button in governance actions dashboard [Issue 1188](https://github.com/IntersectMBO/govtool/issues/1188)
- Add click handlers to non-interactive elements [Issue 2929](https://github.com/IntersectMBO/govtool/issues/2929)
- Allow searching for yourself in DRep Directory [Issue 2993](https://github.com/IntersectMBO/govtool/issues/2993)

### Fixed

Expand Down
29 changes: 9 additions & 20 deletions govtool/frontend/src/pages/DRepDirectoryContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ export const DRepDirectoryContent: FC<DRepDirectoryContentProps> = ({
enabled: !!inProgressDelegation || !!currentDelegation,
});

const { dRep: yourselfDRep } = useGetDRepDetailsQuery(myDRepId, {
enabled: !!inProgressDelegation || !!currentDelegation,
});
const showYourselfDRep =
debouncedSearchText === myDRepId || debouncedSearchText === "";

const {
dRepData: dRepList,
isPreviousData,
Expand Down Expand Up @@ -106,21 +100,16 @@ export const DRepDirectoryContent: FC<DRepDirectoryContentProps> = ({

const ada = correctAdaFormat(votingPower);

const listedDRepsWithoutYourself = uniqBy(
dRepList?.filter(
(dRep) =>
(typeof dRep.doNotList === "string"
? !parseBoolean(dRep.doNotList)
: !dRep.doNotList) && !isSameDRep(dRep, myDRepId),
),
const filteredDoNotListDReps = uniqBy(
dRepList?.filter((dRep) => {
if (typeof dRep.doNotList === "string") {
return !parseBoolean(dRep.doNotList);
}
return !dRep.doNotList;
}),
"view",
);

const dRepListToDisplay =
yourselfDRep && showYourselfDRep
? [yourselfDRep, ...listedDRepsWithoutYourself]
: listedDRepsWithoutYourself;

const isAnAutomatedVotingOptionChosen =
currentDelegation?.dRepView &&
(currentDelegation?.dRepView ===
Expand Down Expand Up @@ -217,8 +206,8 @@ export const DRepDirectoryContent: FC<DRepDirectoryContentProps> = ({
flex: 1,
}}
>
{dRepListToDisplay?.length === 0 && <EmptyStateDrepDirectory />}
{dRepListToDisplay?.map((dRep) => (
{filteredDoNotListDReps?.length === 0 && <EmptyStateDrepDirectory />}
{filteredDoNotListDReps?.map((dRep) => (
<Box key={dRep.view} component="li" sx={{ listStyle: "none" }}>
<DRepCard
dRep={dRep}
Expand Down