1 |
e49b1f44
|
Schwobik
|
import {
|
2 |
|
|
Center,
|
3 |
4da7b143
|
Schwobik
|
ScrollView,
|
4 |
e49b1f44
|
Schwobik
|
VStack
|
5 |
|
|
} from "native-base"
|
6 |
9c55d3bb
|
Schwobik
|
import ListView from "../components/listView/ListView"
|
7 |
|
|
import SearchForm from "../components/search/SearchForm"
|
8 |
4da7b143
|
Schwobik
|
import { useEffect } from "react"
|
9 |
e49b1f44
|
Schwobik
|
import {
|
10 |
4da7b143
|
Schwobik
|
fetchArtists,
|
11 |
|
|
fetchCities,
|
12 |
|
|
fetchCountries,
|
13 |
|
|
fetchInstitutions,
|
14 |
e49b1f44
|
Schwobik
|
fetchInventories,
|
15 |
|
|
fetchNationalities,
|
16 |
|
|
fetchPlans,
|
17 |
4da7b143
|
Schwobik
|
fetchSubjects,
|
18 |
|
|
fetchTechniques
|
19 |
e49b1f44
|
Schwobik
|
} from "../stores/actions/searchFormThunks"
|
20 |
2b71499c
|
Fantič
|
import { useDispatch, useSelector } from "react-redux"
|
21 |
|
|
import { AppDispatch, RootState } from "../stores/store"
|
22 |
e49b1f44
|
Schwobik
|
import { log } from "../logging/logger"
|
23 |
04928342
|
Schwobik
|
import { DrawerScreenProps } from "@react-navigation/drawer"
|
24 |
4da7b143
|
Schwobik
|
import { RootDrawerParamList } from "./Navigation"
|
25 |
2b71499c
|
Fantič
|
import { loadItemsByInventory } from "../stores/actions/listViewThunks"
|
26 |
b7014ba2
|
Schwobik
|
|
27 |
e49b1f44
|
Schwobik
|
|
28 |
4da7b143
|
Schwobik
|
const SearchPage = ({route, navigation}: DrawerScreenProps<RootDrawerParamList, 'Search'>) => {
|
29 |
e49b1f44
|
Schwobik
|
const dispatch = useDispatch<AppDispatch>()
|
30 |
|
|
|
31 |
2b71499c
|
Fantič
|
const inventories = useSelector((state: RootState) => state.listView.inventories)
|
32 |
|
|
const numberOfResults = useSelector((state: RootState) => state.listView.numOfResults)
|
33 |
|
|
|
34 |
|
|
const data = useSelector((state: RootState) => state.listView.data)
|
35 |
|
|
const dataLoading = useSelector((state: RootState) => state.listView.inventoriesDataLoading)
|
36 |
|
|
const pagination = useSelector((state: RootState) => state.listView.loadedPages)
|
37 |
|
|
|
38 |
|
|
|
39 |
e49b1f44
|
Schwobik
|
useEffect(() => {
|
40 |
|
|
log.debug("SearchPage", "useEffect", "fetchEverything")
|
41 |
|
|
|
42 |
|
|
dispatch(fetchInventories())
|
43 |
|
|
dispatch(fetchNationalities())
|
44 |
|
|
dispatch(fetchArtists())
|
45 |
|
|
dispatch(fetchSubjects())
|
46 |
|
|
dispatch(fetchPlans())
|
47 |
|
|
dispatch(fetchTechniques())
|
48 |
|
|
dispatch(fetchCountries())
|
49 |
|
|
dispatch(fetchCities())
|
50 |
|
|
dispatch(fetchInstitutions())
|
51 |
|
|
|
52 |
|
|
log.debug("SearchPage", "useEffect", "fetchEverything", "done")
|
53 |
|
|
}, [dispatch])
|
54 |
b7014ba2
|
Schwobik
|
|
55 |
4da7b143
|
Schwobik
|
|
56 |
|
|
useEffect(() => {
|
57 |
|
|
log.debug("SearchPage", "props", route.params.inventoryId)
|
58 |
|
|
}, [])
|
59 |
|
|
|
60 |
2b71499c
|
Fantič
|
console.log(data)
|
61 |
|
|
|
62 |
b7014ba2
|
Schwobik
|
return (
|
63 |
1980ed09
|
Schwobik
|
<Center m={ 2 } mr={0} mb={6} flex={1}>
|
64 |
|
|
|
65 |
e49b1f44
|
Schwobik
|
<ScrollView flex={1} w={"100%"} >
|
66 |
1980ed09
|
Schwobik
|
<VStack space={ 1 } mr={ 4 }>
|
67 |
4da7b143
|
Schwobik
|
<SearchForm inventoryId={route.params.inventoryId}/>
|
68 |
2b71499c
|
Fantič
|
<ListView navigation={navigation}
|
69 |
|
|
|
70 |
|
|
inventories={inventories}
|
71 |
|
|
numOfResults={numberOfResults}
|
72 |
|
|
|
73 |
|
|
data={data}
|
74 |
|
|
loadedPages={pagination}
|
75 |
|
|
inventoriesDataLoading={dataLoading}
|
76 |
|
|
handleLoadMoreItems={(inventoryName: string, cursor: number) => {
|
77 |
|
|
dispatch(loadItemsByInventory(inventoryName))
|
78 |
|
|
} }/>
|
79 |
ca53e9f1
|
Schwobik
|
</VStack>
|
80 |
|
|
</ScrollView>
|
81 |
e49b1f44
|
Schwobik
|
</Center>
|
82 |
b7014ba2
|
Schwobik
|
)
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
export default SearchPage
|