index.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import React from "react";
  2. import { Link } from "react-router-dom";
  3. import ElectionStatus from "./ElectionStatus";
  4. import User from "../User";
  5. import Loading from "../Loading";
  6. const Member = (props: { id: number; findHandle: (id: number) => string }) => {
  7. const handle = props.findHandle(props.id);
  8. return (
  9. <div className="col">
  10. <User id={handle} handle={handle} />
  11. </div>
  12. );
  13. };
  14. const Council = (props: {
  15. findHandle: (id: number) => string;
  16. council: number[];
  17. councilElection?: any;
  18. block: number;
  19. termEndsAt: number;
  20. }) => {
  21. const { findHandle, council, block, councilElection, termEndsAt } = props;
  22. const half = Math.floor(council.length / 2);
  23. const show = council.length ? true : false;
  24. return (
  25. <div className="box">
  26. <ElectionStatus
  27. show={show}
  28. termEndsAt={termEndsAt}
  29. block={block}
  30. {...councilElection}
  31. />
  32. <h3>Council</h3>
  33. {(show && (
  34. <div className="d-flex flex-column">
  35. <div className="d-flex flex-row">
  36. {council.slice(0, half).map((id) => (
  37. <Member key={String(id)} id={id} findHandle={findHandle} />
  38. ))}
  39. </div>
  40. <div className="d-flex flex-row">
  41. {council.slice(half).map((id) => (
  42. <Member key={String(id)} id={id} findHandle={findHandle} />
  43. ))}
  44. </div>
  45. </div>
  46. )) || <Loading />}
  47. <hr />
  48. <Link to={`/tokenomics`}>Reports</Link>
  49. </div>
  50. );
  51. };
  52. export default Council;