From 6da4106d4cdea8a6d3073021c4b7968f48f2b368 Mon Sep 17 00:00:00 2001 From: Jan Jaroszczak Date: Wed, 8 May 2024 23:22:52 +0200 Subject: [PATCH] [#907] Move DRep yourself card to top in DRep Directory --- .../frontend/src/pages/DRepDirectoryContent.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/govtool/frontend/src/pages/DRepDirectoryContent.tsx b/govtool/frontend/src/pages/DRepDirectoryContent.tsx index efd8a61ad..49a47be2f 100644 --- a/govtool/frontend/src/pages/DRepDirectoryContent.tsx +++ b/govtool/frontend/src/pages/DRepDirectoryContent.tsx @@ -58,6 +58,11 @@ export const DRepDirectoryContent: FC = ({ ); const myDrep = myDRepList?.[0]; + const { dRepData: yourselfDRepList } = useGetDRepListInfiniteQuery({ + searchPhrase: myDRepId, + }); + const yourselfDRep = yourselfDRepList?.[0]; + const { dRepData: dRepList, isPreviousData, @@ -84,6 +89,13 @@ export const DRepDirectoryContent: FC = ({ const ada = correctAdaFormat(votingPower); + const dRepsWithoutYourself = dRepList?.filter( + (dRep) => !isSameDRep(dRep, myDRepId), + ); + const dRepListToDisplay = yourselfDRep + ? [yourselfDRep, ...dRepsWithoutYourself] + : dRepList; + return ( {/* My delegation */} @@ -96,6 +108,7 @@ export const DRepDirectoryContent: FC = ({ dRep={myDrep} isConnected={!!isConnected} isInProgress={isSameDRep(myDrep, inProgressDelegation)} + isMe={isSameDRep(myDrep, myDRepId)} /> )} @@ -175,7 +188,7 @@ export const DRepDirectoryContent: FC = ({ )} - {dRepList?.map((dRep) => { + {dRepListToDisplay?.map((dRep) => { if (isSameDRep(dRep, myDrep?.view)) { return null; }