Projekt

Obecné

Profil

Stáhnout (1.77 KB) Statistiky
| Větev: | Tag: | Revize:
1
import { useEffect, useState } from "react"
2
import { ScrollView, Text, VStack } from "native-base"
3
import { useSelector } from "react-redux"
4
import { RootState } from "../../stores/store"
5
import ItemPreview from "./ItemPreview"
6
import { ItemPreviewType } from "../../types/listViewTypes"
7
import { log } from "../../logging/logger"
8
import ListViewInventoryGroup from "./ListViewInventoryGroup"
9

    
10
type ListViewProps = {
11
    navigation: any
12
}
13

    
14
const ListView = (props: ListViewProps) => {
15

    
16
    const inventories = useSelector((state: RootState) => state.listView.inventories)
17
    const numberOfResults = useSelector((state: RootState) => state.listView.numOfResults)
18

    
19

    
20
    return (
21
        <>
22
            <Text fontSize={ 16 } fontWeight={ "bold" } color={"primary.500"}>Search results{numberOfResults ? ` (${numberOfResults})` : ""}:</Text>
23
            { inventories && inventories.length > 0 ?
24
                (inventories.length > 1 ?
25
                    inventories.map((inventory) => (
26
                            <ListViewInventoryGroup
27
                                inventoryName={ inventory.name }
28
                                inventoryLabel={ inventory.label }
29
                                navigation={ props.navigation }
30
                            />
31
                        )
32
                    ) : (
33
                        <ListViewInventoryGroup
34
                            inventoryName={ inventories[0].name }
35
                            inventoryLabel={ inventories[0].label }
36
                            navigation={ props.navigation }
37
                            defaultOpen={ true }
38
                        />
39
                    )) : (
40
                    <Text alignSelf={ "center" }>No results found</Text>
41
                )
42
            }
43
        </>
44
    )
45
}
46

    
47
export default ListView
(3-3/4)