Projekt

Obecné

Profil

Stáhnout (2.37 KB) Statistiky
| Větev: | Tag: | Revize:
1
import {
2
    Button,
3
    Center,
4
    ChevronDownIcon,
5
    ChevronUpIcon, ScrollView,
6
    VStack
7
} from "native-base"
8
import ListView from "../components/listView/ListView"
9
import SearchForm from "../components/search/SearchForm"
10
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
import { DrawerScreenProps } from "@react-navigation/drawer"
22
import { RootDrawerParamList } from "../components/Navigation"
23

    
24
const SearchPage = ({navigation}: DrawerScreenProps<RootDrawerParamList, 'Search'>) => {
25
    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

    
45
    return (
46
        <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
                    <ListView navigation={navigation}/>
68
                </VStack>
69
            </ScrollView>
70
        </Center>
71
    )
72
}
73

    
74
export default SearchPage
(6-6/6)