Projekt

Obecné

Profil

Stáhnout (1.77 KB) Statistiky
| Větev: | Tag: | Revize:
1 9c55d3bb Schwobik
import { useEffect, useState } from "react"
2 ca53e9f1 Schwobik
import { ScrollView, Text, VStack } from "native-base"
3 9c55d3bb Schwobik
import { useSelector } from "react-redux"
4
import { RootState } from "../../stores/store"
5 ca53e9f1 Schwobik
import ItemPreview from "./ItemPreview"
6 e49b1f44 Schwobik
import { ItemPreviewType } from "../../types/listViewTypes"
7
import { log } from "../../logging/logger"
8 ca44ce3d Schwobik
import ListViewInventoryGroup from "./ListViewInventoryGroup"
9 e49b1f44 Schwobik
10 04928342 Schwobik
type ListViewProps = {
11
    navigation: any
12
}
13 9c55d3bb Schwobik
14 04928342 Schwobik
const ListView = (props: ListViewProps) => {
15 9c55d3bb Schwobik
16 ca44ce3d Schwobik
    const inventories = useSelector((state: RootState) => state.listView.inventories)
17 cbf81c55 Schwobik
    const numberOfResults = useSelector((state: RootState) => state.listView.numOfResults)
18 e49b1f44 Schwobik
19
20 9c55d3bb Schwobik
    return (
21 e49b1f44 Schwobik
        <>
22 cbf81c55 Schwobik
            <Text fontSize={ 16 } fontWeight={ "bold" } color={"primary.500"}>Search results{numberOfResults ? ` (${numberOfResults})` : ""}:</Text>
23 1980ed09 Schwobik
            { inventories && inventories.length > 0 ?
24
                (inventories.length > 1 ?
25
                    inventories.map((inventory) => (
26
                            <ListViewInventoryGroup
27 6c38c709 Schwobik
                                inventoryName={ inventory.name }
28
                                inventoryLabel={ inventory.label }
29 1980ed09 Schwobik
                                navigation={ props.navigation }
30
                            />
31
                        )
32
                    ) : (
33
                        <ListViewInventoryGroup
34 6c38c709 Schwobik
                            inventoryName={ inventories[0].name }
35
                            inventoryLabel={ inventories[0].label }
36 1980ed09 Schwobik
                            navigation={ props.navigation }
37
                            defaultOpen={ true }
38
                        />
39
                    )) : (
40
                    <Text alignSelf={ "center" }>No results found</Text>
41 ca44ce3d Schwobik
                )
42 1980ed09 Schwobik
            }
43 e49b1f44 Schwobik
        </>
44 9c55d3bb Schwobik
    )
45
}
46
47
export default ListView