index.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import React, { useState, useEffect, FC } from "react";
  2. import { generalTable } from "../../../api/tables";
  3. import { Summary } from "../../../types/summary";
  4. import { TableHeader as Header, TdGroup } from "../shared";
  5. import * as classes from "../tables.module.css";
  6. const TemperaturePerSector: FC = () => {
  7. const [data, setData] = useState<Summary[]>([]);
  8. useEffect(() => {
  9. generalTable("", "", "").then((res) => {
  10. setData(JSON.parse(res));
  11. });
  12. }, []);
  13. // Formato de los summaries(filas)
  14. const rows = data?.map((x) => (
  15. <tr key={x.station.code}>
  16. <th className={classes.cell}>{x.station.name}</th>
  17. <TdGroup>
  18. <td>{x.lt10}%</td>
  19. <td>{x.gt30}%</td>
  20. <td>{x.gt33}%</td>
  21. </TdGroup>
  22. <td className={classes.cell}>{x.grados_acumulados}</td>
  23. <td className={classes.cell}>{x.amplitud_termica}</td>
  24. <td className={classes.cell}>{x.precip_acumulada}</td>
  25. </tr>
  26. ));
  27. return (
  28. <table className={classes.table}>
  29. <Header daysToMatchCurrentTemperature={false} />
  30. <tbody>{rows}</tbody>
  31. </table>
  32. );
  33. };
  34. export default TemperaturePerSector;