@@ -3,10 +3,11 @@ import { FormContext, useForm } from "react-hook-form"
3
3
import { toast } from "react-toastify"
4
4
5
5
import Api from "../../services/api"
6
- import { ReportContainer , ReportTable } from "./styles"
6
+ import { ReportContainer , ReportTable , ReportForm } from "./styles"
7
7
8
8
interface ReportFormData {
9
- date : string
9
+ init : string
10
+ end : string
10
11
}
11
12
12
13
interface ReportData {
@@ -35,7 +36,13 @@ const Report: React.FC = () => {
35
36
console . log ( data )
36
37
const reportResponse = await Api . get < ReportData [ ] > ( {
37
38
pathUrl : "/statistics" ,
38
- config : { params : { city : process . env . REACT_APP_CITY , date : data . date } } ,
39
+ config : {
40
+ params : {
41
+ init : data . init ,
42
+ end : data . end ,
43
+ city : process . env . REACT_APP_CITY ,
44
+ } ,
45
+ } ,
39
46
} )
40
47
41
48
if ( ! reportResponse ) {
@@ -63,16 +70,19 @@ const Report: React.FC = () => {
63
70
< section >
64
71
< h1 > Relatório</ h1 >
65
72
< FormContext { ...form } >
66
- < form onSubmit = { form . handleSubmit ( handleFetchReport ) } >
67
- < label htmlFor = "date" > Data </ label >
68
- < input
69
- name = "date"
70
- type = "month"
71
- max = { new Date ( ) . toISOString ( ) }
72
- ref = { form . register }
73
- />
73
+ < ReportForm onSubmit = { form . handleSubmit ( handleFetchReport ) } >
74
+ < div >
75
+ < div >
76
+ < label htmlFor = "init" > Data de inicio</ label >
77
+ < input name = "init" type = "date" ref = { form . register } />
78
+ </ div >
79
+ < div >
80
+ < label htmlFor = "init" > Data de fim</ label >
81
+ < input name = "end" type = "date" ref = { form . register } />
82
+ </ div >
83
+ </ div >
74
84
< button type = "submit" > Gerar relatório</ button >
75
- </ form >
85
+ </ ReportForm >
76
86
</ FormContext >
77
87
</ section >
78
88
< section >
0 commit comments