ProposalOverlay.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React from "react";
  2. import { OverlayTrigger, Tooltip } from "react-bootstrap";
  3. import htmr from "htmr";
  4. const ProposalOverlay = (props: any) => {
  5. const { block, createdAt, parameters } = props;
  6. const remainingBlocks = +createdAt + +parameters.votingPeriod - block;
  7. const remainingTime = remainingBlocks * 6;
  8. const days = Math.floor(remainingTime / 86400);
  9. const hours = Math.floor((remainingTime - days * 86400) / 3600);
  10. return (
  11. <OverlayTrigger
  12. key={createdAt}
  13. placement="right"
  14. delay={{ show: 250, hide: 400 }}
  15. overlay={
  16. <Tooltip id={props.title}>
  17. <div>
  18. Time to vote: {remainingBlocks} blocks ({days}d {hours}h)
  19. </div>
  20. <div className="my-2 p-1 bg-light text-secondary text-left">
  21. {props.message.split(/\n/).map((line: string) => (
  22. <div>{htmr(line)}</div>
  23. ))}
  24. </div>
  25. {props.description}
  26. </Tooltip>
  27. }
  28. >
  29. <div>
  30. <a href={`https://pioneer.joystreamstats.live/#/proposals/${props.id}`}>
  31. {props.title}
  32. </a>
  33. </div>
  34. </OverlayTrigger>
  35. );
  36. };
  37. export default ProposalOverlay;