Newer
Older
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
import React, { useState } from 'react';
import '../../style/style.css';
const DataForm = ({ onSubmit }) => {
const [startDate, setStartDate] = useState('');
const [endDate, setEndDate] = useState('');
const [granularity, setGranularity] = useState('month');
const handleSubmit = (event) => {
event.preventDefault();
onSubmit({ startDate, endDate, granularity });
};
return (
<form onSubmit={handleSubmit} className="form-container">
<input
type="date"
value={startDate}
onChange={(e) => setStartDate(e.target.value)}
required
/>
<input
type="date"
value={endDate}
onChange={(e) => setEndDate(e.target.value)}
required
/>
<select
value={granularity}
onChange={(e) => setGranularity(e.target.value)}
>
<option value="day">Jour</option>
<option value="month">Mois</option>
<option value="year">Année</option>
</select>
<button type="submit">Soumettre</button>
</form>
);
};
export default DataForm;