1
1
import T from 'prop-types' ;
2
2
import { useCallback , useMemo } from 'react' ;
3
3
4
- import { useCollections , StacApi } from "stac-react" ;
5
-
6
4
import { PrimaryButton } from "../../components/buttons" ;
7
5
import { Checkbox , Legend } from '../../components/form' ;
8
6
import { H2 } from "../../components/headers" ;
@@ -11,7 +9,8 @@ import Section from '../../layout/Section';
11
9
12
10
function QueryBuilder ( {
13
11
setIsBboxDrawEnabled,
14
- collections : selectedCollections ,
12
+ collections,
13
+ selectedCollections,
15
14
setCollections,
16
15
handleSubmit,
17
16
dateRangeFrom,
@@ -24,15 +23,8 @@ function QueryBuilder ({
24
23
const handleRangeFromChange = useCallback ( ( e ) => setDateRangeFrom ( e . target . value ) , [ setDateRangeFrom ] ) ;
25
24
const handleRangeToChange = useCallback ( ( e ) => setDateRangeTo ( e . target . value ) , [ setDateRangeTo ] ) ;
26
25
27
- const headers = useMemo ( ( ) => ( {
28
- Authorization : "Basic " + btoa ( process . env . REACT_APP_STAC_API_TOKEN + ":" )
29
- } ) , [ ] ) ;
30
-
31
- const stacApi = useMemo ( ( ) => new StacApi ( process . env . REACT_APP_STAC_API , { headers } ) , [ headers ] ) ;
32
- const { collections } = useCollections ( stacApi ) ;
33
-
34
26
const collectionOptions = useMemo (
35
- ( ) => collections ? collections . collections . map ( ( { id, title } ) => ( { value : id , label : title } ) ) : [ ] ,
27
+ ( ) => collections . collections ? collections . collections . map ( ( { id, title } ) => ( { value : id , label : title } ) ) : [ ] ,
36
28
[ collections ]
37
29
) ;
38
30
@@ -45,7 +37,7 @@ function QueryBuilder ({
45
37
label = "Select Collections"
46
38
name = "collections"
47
39
options = { collectionOptions }
48
- values = { selectedCollections }
40
+ values = { selectedCollections || [ ] }
49
41
onChange = { setCollections }
50
42
/>
51
43
</ Section >
@@ -74,7 +66,8 @@ function QueryBuilder ({
74
66
QueryBuilder . propTypes = {
75
67
setIsBboxDrawEnabled : T . func . isRequired ,
76
68
handleSubmit : T . func . isRequired ,
77
- collections : T . arrayOf ( T . string ) ,
69
+ collections : T . object ,
70
+ selectedCollections : T . arrayOf ( T . string ) ,
78
71
setCollections : T . func . isRequired ,
79
72
dateRangeFrom : T . string . isRequired ,
80
73
setDateRangeFrom : T . func . isRequired ,
0 commit comments