Burns.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import React from "react";
  2. import Chart from "../Chart";
  3. import { Link } from "react-router-dom";
  4. import { Exchange } from "../../types";
  5. const Burns = (props: {
  6. exchanges: Exchange[];
  7. executed: number;
  8. percent: number;
  9. }) => {
  10. const { exchanges, executed, percent } = props;
  11. if (!exchanges) return <div />;
  12. const data = exchanges.map((b) => {
  13. return {
  14. time: b.logTime.split("T")[0],
  15. amount: Math.floor(b.amountUSD),
  16. status: b.status,
  17. };
  18. });
  19. const pctRounded = (100 * percent).toFixed(2);
  20. return (
  21. <div className="p-5 w-100 overflow-hidden">
  22. <Chart
  23. data={data}
  24. x="time"
  25. y="amount"
  26. xLabel="Date"
  27. yLabel="$"
  28. scaleY={true}
  29. pixels={150}
  30. barStyle={(o: Exchange) =>
  31. o.status === "PENDING" ? `bg-warning` : `bg-danger`
  32. }
  33. />
  34. <div className="my-1">
  35. Total Amount Burned: {executed.toFixed(2)} M JOY ({pctRounded}%) -{" "}
  36. <Link className="p-1 text-warning" to={`/burners`}>
  37. <b>Top Burners</b>
  38. </Link>
  39. </div>
  40. </div>
  41. );
  42. };
  43. export default Burns;