Feat:Added new input Field for Size of Land

This commit is contained in:
2025-02-22 23:53:13 +05:30
parent 66a6ac22d0
commit 341a3a127b
+23 -1
View File
@@ -1,14 +1,16 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { useNavigate } from "react-router-dom";
const AddFarm = () => { const AddFarm = () => {
const [isModalOpen, setIsModalOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false);
const [farmName, setFarmName] = useState(""); const [farmName, setFarmName] = useState("");
const [location, setLocation] = useState(""); const [location, setLocation] = useState("");
const [waterContent, setWaterContent] = useState(""); const [waterContent, setWaterContent] = useState("");
const [sizeContent, setSizeContent] = useState("");
const [soilType, setSoilType] = useState(""); const [soilType, setSoilType] = useState("");
const [error, setError] = useState(null); const [error, setError] = useState(null);
const [success, setSuccess] = useState(false); const [success, setSuccess] = useState(false);
const navigator = useNavigate();
const handleSubmit = async (e) => { const handleSubmit = async (e) => {
e.preventDefault(); e.preventDefault();
const farmData = { const farmData = {
@@ -16,6 +18,7 @@ const AddFarm = () => {
location, location,
waterContent, waterContent,
soilType, soilType,
size: sizeContent,
}; };
console.log(farmData); console.log(farmData);
@@ -37,6 +40,7 @@ const AddFarm = () => {
throw new Error("Failed to add farm"); throw new Error("Failed to add farm");
} }
navigator("farmpage");
setSuccess(true); setSuccess(true);
setError(null); setError(null);
setIsModalOpen(false); setIsModalOpen(false);
@@ -180,6 +184,24 @@ const AddFarm = () => {
/> />
</div> </div>
<div>
<label
htmlFor="waterContent"
className="block text-sm font-semibold text-gray-700 mb-2"
>
Size of Land
</label>
<input
type="text"
id="waterContent"
value={sizeContent}
onChange={(e) => setSizeContent(e.target.value)}
className="w-full px-4 py-3 rounded-lg border border-gray-200 focus:ring-2 focus:ring-green-400 focus:border-transparent transition duration-200 ease-in-out bg-white/80"
placeholder="Enter water content"
required
/>
</div>
<div> <div>
<label <label
htmlFor="soilType" htmlFor="soilType"