Skip to content

Commit

Permalink
Merge pull request #961 from IntersectMBO/907-move-drep-yourself-card…
Browse files Browse the repository at this point in the history
…-to-top

[#907] Move DRep yourself card to top in DRep Directory
  • Loading branch information
JanJaroszczak authored May 9, 2024
2 parents 6c01a1e + 6da4106 commit 3e487f8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion govtool/frontend/src/pages/DRepDirectoryContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export const DRepDirectoryContent: FC<DRepDirectoryContentProps> = ({
);
const myDrep = myDRepList?.[0];

const { dRepData: yourselfDRepList } = useGetDRepListInfiniteQuery({
searchPhrase: myDRepId,
});
const yourselfDRep = yourselfDRepList?.[0];

const {
dRepData: dRepList,
isPreviousData,
Expand All @@ -84,6 +89,13 @@ export const DRepDirectoryContent: FC<DRepDirectoryContentProps> = ({

const ada = correctAdaFormat(votingPower);

const dRepsWithoutYourself = dRepList?.filter(
(dRep) => !isSameDRep(dRep, myDRepId),
);
const dRepListToDisplay = yourselfDRep
? [yourselfDRep, ...dRepsWithoutYourself]
: dRepList;

return (
<Box display="flex" flex={1} flexDirection="column" gap={4}>
{/* My delegation */}
Expand Down Expand Up @@ -176,7 +188,7 @@ export const DRepDirectoryContent: FC<DRepDirectoryContentProps> = ({
</Typography>
</Card>
)}
{dRepList?.map((dRep) => {
{dRepListToDisplay?.map((dRep) => {
if (isSameDRep(dRep, myDrep?.view)) {
return null;
}
Expand Down

0 comments on commit 3e487f8

Please sign in to comment.