1 |
e49b1f44
|
Schwobik
|
import {
|
2 |
|
|
Button,
|
3 |
|
|
Center,
|
4 |
|
|
ChevronDownIcon,
|
5 |
|
|
ChevronUpIcon, ScrollView,
|
6 |
|
|
VStack
|
7 |
|
|
} from "native-base"
|
8 |
9c55d3bb
|
Schwobik
|
import ListView from "../components/listView/ListView"
|
9 |
|
|
import SearchForm from "../components/search/SearchForm"
|
10 |
e49b1f44
|
Schwobik
|
import { useEffect, useState } from "react"
|
11 |
|
|
import {
|
12 |
|
|
fetchArtists, fetchCities, fetchCountries, fetchInstitutions,
|
13 |
|
|
fetchInventories,
|
14 |
|
|
fetchNationalities,
|
15 |
|
|
fetchPlans,
|
16 |
|
|
fetchSubjects, fetchTechniques
|
17 |
|
|
} from "../stores/actions/searchFormThunks"
|
18 |
|
|
import { useDispatch } from "react-redux"
|
19 |
|
|
import { AppDispatch } from "../stores/store"
|
20 |
|
|
import { log } from "../logging/logger"
|
21 |
04928342
|
Schwobik
|
import { DrawerScreenProps } from "@react-navigation/drawer"
|
22 |
|
|
import { RootDrawerParamList } from "../components/Navigation"
|
23 |
b7014ba2
|
Schwobik
|
|
24 |
04928342
|
Schwobik
|
const SearchPage = ({navigation}: DrawerScreenProps<RootDrawerParamList, 'Search'>) => {
|
25 |
e49b1f44
|
Schwobik
|
const [isFilterOpen, setIsFilterOpen] = useState(true)
|
26 |
|
|
|
27 |
|
|
const dispatch = useDispatch<AppDispatch>()
|
28 |
|
|
|
29 |
|
|
useEffect(() => {
|
30 |
|
|
log.debug("SearchPage", "useEffect", "fetchEverything")
|
31 |
|
|
|
32 |
|
|
dispatch(fetchInventories())
|
33 |
|
|
dispatch(fetchNationalities())
|
34 |
|
|
dispatch(fetchArtists())
|
35 |
|
|
dispatch(fetchSubjects())
|
36 |
|
|
dispatch(fetchPlans())
|
37 |
|
|
dispatch(fetchTechniques())
|
38 |
|
|
dispatch(fetchCountries())
|
39 |
|
|
dispatch(fetchCities())
|
40 |
|
|
dispatch(fetchInstitutions())
|
41 |
|
|
|
42 |
|
|
log.debug("SearchPage", "useEffect", "fetchEverything", "done")
|
43 |
|
|
}, [dispatch])
|
44 |
b7014ba2
|
Schwobik
|
|
45 |
|
|
return (
|
46 |
e49b1f44
|
Schwobik
|
<Center m={ 2 } mr={ 4 } flex={1}>
|
47 |
|
|
<Button
|
48 |
|
|
alignSelf={ "start" }
|
49 |
|
|
onPress={ () => setIsFilterOpen(!isFilterOpen) }
|
50 |
|
|
variant="outline"
|
51 |
|
|
endIcon={
|
52 |
|
|
<>
|
53 |
|
|
{ isFilterOpen ?
|
54 |
|
|
(<ChevronUpIcon size={ 4 } color={ "primary.500" }/>)
|
55 |
|
|
: (<ChevronDownIcon size={ 4 } color={ "primary.500" }/>) }
|
56 |
|
|
</>
|
57 |
|
|
}
|
58 |
|
|
flexWrap={ "nowrap" }
|
59 |
|
|
borderColor={ "primary.500" }
|
60 |
|
|
mb={ 2 }
|
61 |
|
|
>
|
62 |
|
|
Filter
|
63 |
|
|
</Button>
|
64 |
|
|
<ScrollView flex={1} w={"100%"} >
|
65 |
|
|
<VStack space={ 1 }>
|
66 |
|
|
<SearchForm isFilterOpen={ isFilterOpen }/>
|
67 |
04928342
|
Schwobik
|
<ListView navigation={navigation}/>
|
68 |
ca53e9f1
|
Schwobik
|
</VStack>
|
69 |
|
|
</ScrollView>
|
70 |
e49b1f44
|
Schwobik
|
</Center>
|
71 |
b7014ba2
|
Schwobik
|
)
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
export default SearchPage
|