Skip to content

Commit 9cabaad

Browse files
committed
Padronizando formulário de relatório e heatmap
1 parent 9fba3fc commit 9cabaad

File tree

3 files changed

+59
-70
lines changed

3 files changed

+59
-70
lines changed

src/pages/StatisticsPage/Heatmap.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const Heatmap: React.FC = () => {
2929
params: {
3030
init: data.init,
3131
end: data.end,
32+
city: process.env.REACT_APP_CITY,
3233
},
3334
},
3435
})

src/pages/StatisticsPage/Report.tsx

+22-12
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { FormContext, useForm } from "react-hook-form"
33
import { toast } from "react-toastify"
44

55
import Api from "../../services/api"
6-
import { ReportContainer, ReportTable } from "./styles"
6+
import { ReportContainer, ReportTable, ReportForm } from "./styles"
77

88
interface ReportFormData {
9-
date: string
9+
init: string
10+
end: string
1011
}
1112

1213
interface ReportData {
@@ -35,7 +36,13 @@ const Report: React.FC = () => {
3536
console.log(data)
3637
const reportResponse = await Api.get<ReportData[]>({
3738
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+
},
3946
})
4047

4148
if (!reportResponse) {
@@ -63,16 +70,19 @@ const Report: React.FC = () => {
6370
<section>
6471
<h1>Relatório</h1>
6572
<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>
7484
<button type="submit">Gerar relatório</button>
75-
</form>
85+
</ReportForm>
7686
</FormContext>
7787
</section>
7888
<section>

src/pages/StatisticsPage/styles.ts

+36-58
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,39 @@ export const NavBar = styled.nav`
2020
}
2121
`
2222

23+
const StyledForm = styled.form`
24+
> div {
25+
display: flex;
26+
27+
> div {
28+
margin-right: 25px;
29+
30+
label {
31+
display: block;
32+
margin-bottom: 4px;
33+
font-size: 16px;
34+
}
35+
36+
input {
37+
border: 2px solid #ddd;
38+
border-radius: 4px;
39+
padding: 4px 8px;
40+
margin-bottom: 8px;
41+
}
42+
}
43+
}
44+
45+
button {
46+
padding: 8px 16px;
47+
border: 2px solid #0b76da;
48+
border-radius: 4px;
49+
background: #0b76da;
50+
color: #fff;
51+
font-size: 18px;
52+
margin-bottom: 5px;
53+
}
54+
`
55+
2356
const Container = styled.article`
2457
padding: 10px 20px;
2558
background: #fff;
@@ -45,34 +78,10 @@ export const ReportContainer = styled(Container)`
4578
display: flex;
4679
justify-content: space-between;
4780
transition: all 0.3s;
48-
49-
form {
50-
label {
51-
display: block;
52-
margin-bottom: 4px;
53-
font-size: 16px;
54-
}
55-
56-
input {
57-
border: 2px solid #ddd;
58-
border-radius: 4px;
59-
padding: 4px 8px;
60-
display: block;
61-
margin-bottom: 8px;
62-
}
63-
64-
button {
65-
padding: 8px 16px;
66-
border: 2px solid #0b76da;
67-
border-radius: 4px;
68-
background: #0b76da;
69-
color: #fff;
70-
font-size: 18px;
71-
margin-bottom: 5px;
72-
}
73-
}
7481
`
7582

83+
export const ReportForm = styled(StyledForm)``
84+
7685
export const ReportTable = styled.table`
7786
border-collapse: collapse;
7887
margin: 25px 0;
@@ -116,38 +125,7 @@ export const HeatmapContainer = styled(Container)`
116125
transition: all 0.3s;
117126
`
118127

119-
export const HeatmapForm = styled.form`
120-
> div {
121-
display: flex;
122-
123-
> div {
124-
margin-right: 25px;
125-
126-
label {
127-
display: block;
128-
margin-bottom: 4px;
129-
font-size: 16px;
130-
}
131-
132-
input {
133-
border: 2px solid #ddd;
134-
border-radius: 4px;
135-
padding: 4px 8px;
136-
margin-bottom: 8px;
137-
}
138-
}
139-
}
140-
141-
button {
142-
padding: 8px 16px;
143-
border: 2px solid #0b76da;
144-
border-radius: 4px;
145-
background: #0b76da;
146-
color: #fff;
147-
font-size: 18px;
148-
margin-bottom: 5px;
149-
}
150-
`
128+
export const HeatmapForm = styled(StyledForm)``
151129

152130
export const MapContainer = styled.div`
153131
display: flex;

0 commit comments

Comments
 (0)