1
- import React , { useState , useEffect } from "react" ;
1
+ import React , { useState } from "react" ;
2
2
import { FormattedMessage } from "react-intl" ;
3
3
import Description from "../Form/Description" ;
4
- import { FormLabel , FormGroup , FormControl } from "react-bootstrap" ;
4
+ import { FormGroup , FormControl } from "react-bootstrap" ;
5
5
6
6
export default function IndividualDateFilter ( { onChange } ) {
7
- const [ startDate , setStartDate ] = useState ( "" ) ;
8
- const [ endDate , setEndDate ] = useState ( "" ) ;
9
7
const [ birthDate , setBirthDate ] = useState ( "" ) ;
10
8
const [ deathDate , setDeathDate ] = useState ( "" ) ;
11
9
12
- useEffect ( ( ) => {
13
- updateQuery1 ( "startDate" , startDate ) ;
14
- } , [ startDate ] ) ;
15
- useEffect ( ( ) => {
16
- updateQuery1 ( "endDate" , endDate ) ;
17
- } , [ endDate ] ) ;
18
-
19
- const updateQuery1 = ( ) => {
20
- if ( startDate || endDate ) {
21
- const query = {
22
- range : {
23
- datematched : { } ,
24
- } ,
25
- } ;
26
-
27
- if ( startDate ) {
28
- query . range . datematched . gte = startDate + "T00:00:00Z" ;
29
- }
30
-
31
- if ( endDate ) {
32
- query . range . datematched . lte = endDate + "T23:59:59Z" ;
33
- }
34
- onChange ( {
35
- filterId : "datematched" ,
36
- filterKey : "Date Matched" ,
37
- clause : "filter" ,
38
- query : query ,
39
- } ) ;
40
- } else {
41
- onChange ( null , "date" ) ;
42
- }
43
- } ;
44
-
45
10
return (
46
11
< div >
47
12
< h4 >
@@ -70,7 +35,7 @@ export default function IndividualDateFilter({ onChange }) {
70
35
gte : `${ e . target . value } T00:00:00.000Z` ,
71
36
lte : `${ e . target . value } T23:59:59.000Z` ,
72
37
} ,
73
- }
38
+ } ,
74
39
} ,
75
40
} ) ;
76
41
} }
@@ -95,43 +60,12 @@ export default function IndividualDateFilter({ onChange }) {
95
60
gte : `${ e . target . value } T00:00:00.000Z` ,
96
61
lte : `${ e . target . value } T23:59:59.000Z` ,
97
62
} ,
98
- }
63
+ } ,
99
64
} ,
100
65
} ) ;
101
66
} }
102
67
/>
103
68
</ FormGroup >
104
- { /* <FormLabel>
105
- <FormattedMessage id="FILTER_DATE_MATCHED" />
106
- </FormLabel>
107
- <div className="d-flex flex-row w-100 mb-2">
108
- <FormGroup className="w-50" style={{ marginRight: "10px" }}>
109
- <p>
110
- <FormattedMessage id="FILTER_FROM" defaultMessage="From" />
111
- </p>
112
- <FormControl
113
- type="date"
114
- value={startDate}
115
- onChange={(e) => {
116
- setStartDate(e.target.value);
117
- updateQuery1();
118
- }}
119
- />
120
- </FormGroup>
121
- <FormGroup className="w-50">
122
- <p>
123
- <FormattedMessage id="FILTER_TO" defaultMessage="To" />
124
- </p>
125
- <FormControl
126
- type="date"
127
- value={endDate}
128
- onChange={(e) => {
129
- setEndDate(e.target.value);
130
- updateQuery1();
131
- }}
132
- />
133
- </FormGroup>
134
- </div> */ }
135
69
</ >
136
70
</ div >
137
71
) ;
0 commit comments