index.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import React from "react";
  2. import { Table } from "react-bootstrap";
  3. import LeaderBoard from "./Leaderboard";
  4. import CouncilVotes from "./CouncilVotes";
  5. import Back from "../Back";
  6. import { Member, ProposalDetail, Seat } from "../../types";
  7. // TODO fetch from chain
  8. const announcingPeriod = 28800;
  9. const votingPeriod = 14400;
  10. const revealingPeriod = 14400;
  11. const termDuration = 144000;
  12. const cycle = termDuration + announcingPeriod + votingPeriod + revealingPeriod; // 201600
  13. const Rounds = (props: {
  14. block: number;
  15. members: Member[];
  16. councils: Seat[][];
  17. proposals: any;
  18. }) => {
  19. const { block, councils, members, proposals } = props;
  20. return (
  21. <div className="w-100">
  22. <div className="position-fixed" style={{ right: "0", top: "0" }}>
  23. <Back />
  24. </div>
  25. <Table className="w-100 text-light">
  26. <thead>
  27. <tr>
  28. <th>Round</th>
  29. <th>Announced</th>
  30. <th>Voted</th>
  31. <th>Revealed</th>
  32. <th>Start</th>
  33. <th>End</th>
  34. </tr>
  35. </thead>
  36. <tbody>
  37. {councils.map((council, i: number) => (
  38. <tr key={i} className="">
  39. <td>{i + 1}</td>
  40. <td>{1 + i * cycle}</td>
  41. <td>{28801 + i * cycle}</td>
  42. <td>{43201 + i * cycle}</td>
  43. <td>{57601 + i * cycle}</td>
  44. <td>{57601 + 201600 + i * cycle}</td>
  45. </tr>
  46. ))}
  47. </tbody>
  48. </Table>
  49. <LeaderBoard
  50. cycle={cycle}
  51. councils={councils}
  52. members={members}
  53. proposals={proposals}
  54. />
  55. <h2 className="w-100 text-center text-light">Votes per Council</h2>
  56. {councils.map((council, i: number) => (
  57. <CouncilVotes
  58. key={i}
  59. expand={i === councils.length - 1}
  60. block={block}
  61. round={i + 1}
  62. council={council}
  63. members={props.members}
  64. proposals={props.proposals.filter(
  65. (p: ProposalDetail) =>
  66. p &&
  67. p.createdAt > 57601 + i * cycle &&
  68. p.createdAt < 57601 + (i + 1) * cycle
  69. )}
  70. />
  71. ))}
  72. </div>
  73. );
  74. };
  75. export default Rounds;