Przeglądaj źródła

Sort council round seats by totalStake.

Oleksandr Korniienko 3 lat temu
rodzic
commit
5b427e4064
1 zmienionych plików z 5 dodań i 1 usunięć
  1. 5 1
      src/components/Councils/CouncilRounds.tsx

+ 5 - 1
src/components/Councils/CouncilRounds.tsx

@@ -13,6 +13,10 @@ import { CouncilRound, ICouncilRounds, SeatData } from "./types";
 const CouncilRounds = (props: { rounds: ICouncilRounds }) => {
   const classes = electionStyles();
 
+  const sortByStake = (seatA: SeatData, seatB: SeatData) => {
+    return seatA.totalStake < seatB.totalStake ? 1 : -1;
+  };
+
   return (
     <Grid className={classes.root} item lg={12}>
       {props.rounds.rounds
@@ -31,7 +35,7 @@ const CouncilRounds = (props: { rounds: ICouncilRounds }) => {
               <AccordionDetails>
                 <Grid item key={index} lg={12}>
                   <Grid container spacing={1}>
-                    {r.seats.map((seat: SeatData, index: number) => (
+                    {r.seats.sort(sortByStake).map((seat: SeatData, index: number) => (
                       <CouncilSeat seat={seat} key={index} />
                     ))}
                   </Grid>