|
|
@@ -16,12 +16,17 @@ import {
|
|
|
|
|
|
const GeneralPerSector: FC = () => {
|
|
|
const [data, setData] = useState<Summary[] | null>(null);
|
|
|
+ const [isLoading, setIsLoading] = useState<boolean>(true);
|
|
|
const { userToken } = useContext(UserStateContext);
|
|
|
const { from, to, sector } = useContext(StateContext);
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (!userToken) return;
|
|
|
- generalTable(from, to, userToken).then(setData);
|
|
|
+ // generalTable(from, to, userToken).then(setData);
|
|
|
+ generalTable(from, to, userToken).then((res) => {
|
|
|
+ setData(res);
|
|
|
+ setIsLoading(false);
|
|
|
+ });
|
|
|
}, [from, to, userToken]);
|
|
|
|
|
|
// Formato de los summaries(filas)
|
|
|
@@ -88,12 +93,12 @@ const GeneralPerSector: FC = () => {
|
|
|
return (
|
|
|
<>
|
|
|
<table className={`${classes.table}`}>
|
|
|
- <Header averageAccumulated />
|
|
|
+ <Header averageAccumulated mainColumnHeader="Finca" />
|
|
|
{/* Mostrar las filas si hay data */}
|
|
|
<tbody>{data && rows}</tbody>
|
|
|
</table>
|
|
|
{/* Si no hay data, mostrar una spinner abajo de la tabla */}
|
|
|
- {!data && (
|
|
|
+ {!data && isLoading && (
|
|
|
<div className="d-flex py-3 justify-content-center">
|
|
|
<div className="spinner-border" role="status">
|
|
|
<span className="visually-hidden">Loading...</span>
|
|
|
@@ -102,7 +107,7 @@ const GeneralPerSector: FC = () => {
|
|
|
)}
|
|
|
{data && data.length === 0 && (
|
|
|
<div className="d-flex py-3 justify-content-center">
|
|
|
- <div className="spinner-border" role="status">
|
|
|
+ <div role="status">
|
|
|
<p>Sin datos</p>
|
|
|
</div>
|
|
|
</div>
|