import { useEffect, useState } from "react"; import Td from "../../../components/Td"; import Laoder from "../../../components/Laoder"; const Transactions = ({ farmId }) => { const [data, setData] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { fetch(`http://localhost:8000/api/v1/finance`, { credentials: "include", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ farm: farmId }), }) .then((response) => response.json()) .then((data) => { setData(data); console.log("Fetched data:", data); setLoading(false); }) .catch((error) => { console.error("Error fetching transactions:", error); setLoading(false); }); }, [farmId]); return (
{loading ? ( ) : ( {Array.isArray(data) && data.length > 0 ? ( data.map((item) => )}
Farm name Location Type Size (acres) Action
) ) : (
No data available
)}
); }; export default Transactions;