Skip to content

Commit

Permalink
[#907] Move DRep yourself card to top in DRep Directory
Browse files Browse the repository at this point in the history
  • Loading branch information
JanJaroszczak committed May 8, 2024
1 parent 1bfd6d8 commit 6da4106
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 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 All @@ -96,6 +108,7 @@ export const DRepDirectoryContent: FC<DRepDirectoryContentProps> = ({
dRep={myDrep}
isConnected={!!isConnected}
isInProgress={isSameDRep(myDrep, inProgressDelegation)}
isMe={isSameDRep(myDrep, myDRepId)}
/>
</div>
)}
Expand Down Expand Up @@ -175,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 6da4106

Please sign in to comment.