Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2b71499c

Přidáno uživatelem Fantič před více než 1 rok

re #10871: ListView refactor

Zobrazit rozdíly:

src/pages/SearchPage.tsx
17 17
    fetchSubjects,
18 18
    fetchTechniques
19 19
} from "../stores/actions/searchFormThunks"
20
import { useDispatch } from "react-redux"
21
import { AppDispatch } from "../stores/store"
20
import { useDispatch, useSelector } from "react-redux"
21
import { AppDispatch, RootState } from "../stores/store"
22 22
import { log } from "../logging/logger"
23 23
import { DrawerScreenProps } from "@react-navigation/drawer"
24 24
import { RootDrawerParamList } from "./Navigation"
25
import { loadItemsByInventory } from "../stores/actions/listViewThunks"
25 26

  
26 27

  
27 28
const SearchPage = ({route, navigation}: DrawerScreenProps<RootDrawerParamList, 'Search'>) => {
28 29
    const dispatch = useDispatch<AppDispatch>()
29 30

  
31
    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

  
30 39
    useEffect(() => {
31 40
        log.debug("SearchPage", "useEffect", "fetchEverything")
32 41

  
......
48 57
        log.debug("SearchPage", "props", route.params.inventoryId)
49 58
    }, [])
50 59

  
60
    console.log(data)
61

  
51 62
    return (
52 63
        <Center m={ 2 } mr={0} mb={6} flex={1}>
53 64

  
54 65
            <ScrollView flex={1} w={"100%"} >
55 66
                <VStack space={ 1 } mr={ 4 }>
56 67
                    <SearchForm inventoryId={route.params.inventoryId}/>
57
                    <ListView navigation={navigation}/>
68
                    <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
                    } }/>
58 79
                </VStack>
59 80
            </ScrollView>
60 81
        </Center>

Také k dispozici: Unified diff