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