Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 6c38c709

Přidáno uživatelem Schwobik před téměř 2 roky(ů)

ListView fix
re #10715

Zobrazit rozdíly:

src/components/listView/ListView.tsx
23 23
                (inventories.length > 1 ?
24 24
                    inventories.map((inventory) => (
25 25
                            <ListViewInventoryGroup
26
                                inventory={ inventory.label }
26
                                inventoryName={ inventory.name }
27
                                inventoryLabel={ inventory.label }
27 28
                                navigation={ props.navigation }
28 29
                            />
29 30
                        )
30 31
                    ) : (
31 32
                        <ListViewInventoryGroup
32
                            inventory={ inventories[0].label }
33
                            inventoryName={ inventories[0].name }
34
                            inventoryLabel={ inventories[0].label }
33 35
                            navigation={ props.navigation }
34 36
                            defaultOpen={ true }
35 37
                        />
src/components/listView/ListViewInventoryGroup.tsx
1
import { Badge, Button, Pressable, VStack, Text, Fab } from "native-base"
1
import { Badge, Button, Pressable, VStack, Text, Fab, Divider } from "native-base"
2 2
import { ItemPreviewType } from "../../types/listViewTypes"
3 3
import ItemPreview from "./ItemPreview"
4 4
import { useDispatch, useSelector } from "react-redux"
......
7 7
import { loadItemsByInventory } from "../../stores/actions/listViewThunks"
8 8

  
9 9
interface ListViewInventoryGroupProps {
10
    inventory: string
10
    inventoryName: string
11
    inventoryLabel: string
11 12
    navigation: any
12 13
    defaultOpen?: boolean
13 14
}
14 15

  
15 16
const ListViewInventoryGroup = (props: ListViewInventoryGroupProps) => {
16
    const items = useSelector((state: RootState) => state.listView.data[props.inventory])
17
    const items = useSelector((state: RootState) => state.listView.data[props.inventoryName])
17 18
    const loading = useSelector((state: RootState) => state.listView.loading)
18 19
    const [isExpanded, setIsExpanded] = useState(props.defaultOpen ? props.defaultOpen : false)
19
    const pagination = useSelector((state: RootState) => state.listView.loadedPages[props.inventory])
20
    const pagination = useSelector((state: RootState) => state.listView.loadedPages[props.inventoryName])
20 21

  
21 22
    const dispatch = useDispatch<AppDispatch>()
22 23

  
......
65 66
    useEffect(() => {
66 67
        if (isExpanded) {
67 68
            if (!items || items.length == 0) {
68
                dispatch(loadItemsByInventory(props.inventory))
69
                dispatch(loadItemsByInventory(props.inventoryName))
69 70
            }
70 71
        }
71 72
    }, [isExpanded])
......
79 80
    useEffect(() => {
80 81
        if (props.defaultOpen) {
81 82
            if (!items || items.length == 0) {
82
                dispatch(loadItemsByInventory(props.inventory))
83
                dispatch(loadItemsByInventory(props.inventoryName))
83 84
            }
84 85
        }
85 86
    }, [])
......
96 97
                    p={ 1 }
97 98
                    size={ "md" }
98 99
                >
99
                    { props.inventory }
100
                    { props.inventoryLabel }
100 101
                </Button>
101 102
                { isExpanded && items && items.map((item) => (
102 103
                    <ItemPreview
......
111 112
                )) }
112 113
                { isExpanded && items && pagination && pagination.cursor < pagination.records && (
113 114
                    <Button
114
                        onPress={ () => dispatch(loadItemsByInventory(props.inventory)) }
115
                        onPress={ () => dispatch(loadItemsByInventory(props.inventoryName)) }
115 116
                        variant={ "Link" }
116
                        mt={ 2 }
117
                        mt={ 0 }
117 118
                        size={ "sm" }
118 119
                        color={ "primary.500" }
119 120
                        textDecoration={ "underline" }
120 121
                    >
121
                        <Text fontSize={ "sm" } color={ "primary.6 00" } underline>Load more</Text>
122
                        <Text fontSize={ "sm" } color={ "primary.500" } underline>Load more</Text>
122 123
                    </Button>
123 124
                ) }
125
                <Divider my={ 2 } colorScheme={"primary"} />
124 126

  
125 127
            </VStack>
126 128
        </>

Také k dispozici: Unified diff