From e98b39a9da66a830c876de46e103d230c06de0d9 Mon Sep 17 00:00:00 2001 From: Atharva Date: Sun, 23 Feb 2025 00:26:27 +0530 Subject: [PATCH] Feat:Added loading text to be replaced with animation after --- Frontend/src/components/FarmList.jsx | 67 +++++++++++++++------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/Frontend/src/components/FarmList.jsx b/Frontend/src/components/FarmList.jsx index 8b647d0..709f080 100644 --- a/Frontend/src/components/FarmList.jsx +++ b/Frontend/src/components/FarmList.jsx @@ -3,7 +3,7 @@ import Td from "./Td"; const FarmList = () => { const [data, setData] = useState([]); - + const [loading, setLoading] = useState(true); useEffect(() => { fetch("http://localhost:8000/api/v1/farm", { credentials: "include", @@ -12,43 +12,48 @@ const FarmList = () => { }) .then((response) => response.json()) .then((data) => setData(data)) + .then(setLoading(false)) .catch((error) => console.error(error)); }, []); return (
- - - - - - - - - - - - {data.length > 0 ? ( - data.map((item) => + {data.length > 0 ? ( + data.map((item) => + + + )} + +
- Farm name - - Location - - Type - - Size (acres) - - Action -
) - ) : ( + {loading ? ( +
Loading...
+ ) : ( + + - + + + + + - )} - -
- No data available - + Farm name + + Location + + Type + + Size (acres) + + Action +
+ +
) + ) : ( +
+ No data available +
+ )}
); };