diff --git a/Frontend/src/pages/UserPanel/Farm/CropTable.jsx b/Frontend/src/pages/UserPanel/Farm/CropTable.jsx index a9fc8f8..b200dd9 100644 --- a/Frontend/src/pages/UserPanel/Farm/CropTable.jsx +++ b/Frontend/src/pages/UserPanel/Farm/CropTable.jsx @@ -4,6 +4,20 @@ const CropTable = ({ farmId }) => { const [crops, setCrops] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); + const handleRemoveCrop = async (cropId) => { + try { + await fetch(`http://localhost:8000/api/v1/crop/${cropId}`, { + method: "DELETE", + credentials: "include", + headers: { + "Content-Type": "application/json", + }, + }); + setCrops(crops.filter((crop) => crop._id !== cropId)); + } catch (err) { + setError(err.message); + } + }; useEffect(() => { const fetchCrops = async () => { try { @@ -31,7 +45,7 @@ const CropTable = ({ farmId }) => { }; fetchCrops(); - }, [farmId]); + }, []); if (loading) { return ( @@ -84,6 +98,9 @@ const CropTable = ({ farmId }) => {