-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetData.jsx
More file actions
242 lines (239 loc) · 7.5 KB
/
Copy pathGetData.jsx
File metadata and controls
242 lines (239 loc) · 7.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
import React, { useState } from "react";
import { useDispatch } from "react-redux";
import { useNavigate } from "react-router-dom";
import { setFormData } from "../../redux/form/formSlice";
const GetData = () => {
const navigate = useNavigate();
const [location, setLocation] = useState("");
const [cropType, setCropType] = useState("");
const [soilType, setSoilType] = useState("");
const [growthStage, setGrowthStage] = useState("");
const dispatch = useDispatch();
const handleSubmit = (e) => {
e.preventDefault();
const formData = {
location,
cropType,
soilType,
growthStage,
};
console.log("Collected Farmer Data: ", formData);
dispatch(setFormData(formData));
navigate("/analyse", { state: formData });
};
const styles = {
container: {
minHeight: "100vh",
backgroundColor: "#f0f9f0",
display: "flex",
alignItems: "center",
justifyContent: "center",
padding: "20px",
fontFamily: "Arial, sans-serif",
},
card: {
backgroundColor: "white",
borderRadius: "8px",
boxShadow: "0 4px 6px rgba(0, 0, 0, 0.1)",
width: "100%",
maxWidth: "600px",
},
header: {
backgroundColor: "#2e7d32",
color: "white",
padding: "20px",
borderTopLeftRadius: "8px",
borderTopRightRadius: "8px",
},
title: {
margin: "0",
fontSize: "24px",
display: "flex",
alignItems: "center",
},
description: {
margin: "10px 0 0",
fontSize: "14px",
color: "#a5d6a7",
},
form: {
padding: "20px",
},
inputGroup: {
marginBottom: "20px",
},
label: {
display: "block",
marginBottom: "5px",
fontWeight: "bold",
},
input: {
width: "100%",
padding: "8px",
border: "1px solid #ccc",
borderRadius: "4px",
fontSize: "16px",
},
select: {
width: "100%",
padding: "8px",
border: "1px solid #ccc",
borderRadius: "4px",
fontSize: "16px",
backgroundColor: "white",
},
button: {
width: "100%",
padding: "10px",
backgroundColor: "#2e7d32",
color: "white",
border: "none",
borderRadius: "4px",
fontSize: "16px",
cursor: "pointer",
},
"@media (max-width: 600px)": {
card: {
width: "100%",
},
},
};
return (
<div style={styles.container}>
<div style={styles.card}>
<div style={styles.header}>
<h2 style={styles.title}>
<span style={{ marginRight: "10px" }}>🍃</span>
Farmer Data Collection Form
</h2>
<p style={styles.description}>
Please fill in the details about your farm and crops
</p>
</div>
<form onSubmit={handleSubmit} style={styles.form}>
<div style={styles.inputGroup}>
<label style={styles.label} htmlFor="location">
Location
</label>
<select
id="location"
style={styles.input}
value={location}
onChange={(e) => setLocation(e.target.value)}
required
>
<option value="">Select Location</option>
<option value="madurai">Madurai</option>
<option value="chennai">Chennai</option>
<option value="delhi">Delhi</option>
<option value="bangalore">Bangalore</option>
<option value="mumbai">Mumbai</option>
<option value="kolkata">Kolkata</option>
<option value="hyderabad">Hyderabad</option>
<option value="pune">Pune</option>
<option value="jaipur">Jaipur</option>
<option value="chandigarh">Chandigarh</option>
<option value="noida">Noida</option>
<option value="gurgaon">Gurgaon</option>
</select>
</div>
<div style={styles.inputGroup}>
<label style={styles.label} htmlFor="cropType">
Crop Type
</label>
<select
id="cropType"
style={styles.select}
value={cropType}
onChange={(e) => setCropType(e.target.value)}
required
>
<option value="">Select Crop Type</option>
<option value="wheat">Wheat</option>
<option value="rice">Rice</option>
<option value="maize">Maize</option>
<option value="soybeans">Soybeans</option>
</select>
</div>
<div style={styles.inputGroup}>
<label style={styles.label} htmlFor="soilType">
Soil Type
</label>
<select
id="soilType"
style={styles.select}
value={soilType}
onChange={(e) => setSoilType(e.target.value)}
required
>
<option value="">Select Soil Type</option>
<option value="clay">Clay</option>
<option value="sandy">Sandy</option>
<option value="loamy">Loamy</option>
<option value="silt">Silt</option>
</select>
</div>
<div style={styles.inputGroup}>
<label style={styles.label} htmlFor="growthStage">
Growth Stage
</label>
<select
id="growthStage"
style={styles.select}
value={growthStage}
onChange={(e) => setGrowthStage(e.target.value)}
required
>
<option value="">Select Growth Stage</option>
<option value="germination">Germination</option>
<option value="vegetative">Vegetative</option>
<option value="reproductive">Reproductive</option>
<option value="ripening">Ripening</option>
</select>
</div>
{/* <div style={styles.inputGroup}>
<label style={styles.label} htmlFor="recentIrrigation">
Recent Irrigation (in mm)
</label>
<input
id="recentIrrigation"
style={styles.input}
type="number"
value={recentIrrigation}
onChange={(e) => setRecentIrrigation(e.target.value)}
required
/>
</div>
<div style={styles.inputGroup}>
<label style={styles.label} htmlFor="fertilizationPractices">
Fertilization Practices
</label>
<textarea
id="fertilizationPractices"
style={styles.input}
value={fertilizationPractices}
onChange={(e) => setFertilizationPractices(e.target.value)}
placeholder="e.g., 50kg Nitrogen applied"
/>
</div>
<div style={styles.inputGroup}>
<label style={styles.label} htmlFor="pestObservations">
Pest/Disease Observations (if any)
</label>
<textarea
id="pestObservations"
style={styles.input}
value={pestObservations}
onChange={(e) => setPestObservations(e.target.value)}
placeholder="e.g., Signs of pest attack on leaves"
/>
</div> */}
<button type="submit" style={styles.button}>
Submit
</button>
</form>
</div>
</div>
);
};
export default GetData;