1 |
091dec61
|
Fantič
|
import { Center, Box, VStack, Button, HStack, Text, Image, ScrollView, View, Spacer, Card, Heading } from "native-base"
|
2 |
852de08e
|
Fantič
|
import React from "react"
|
3 |
b88520f8
|
Fantič
|
import { Item } from "../../types/item"
|
4 |
|
|
import { Note } from "../../types/note"
|
5 |
a7a9a204
|
Fantič
|
import LoadingBox from "../loading/LoadingBox"
|
6 |
cb25df10
|
Fantič
|
import NotesListView from "../notes/NotesListView"
|
7 |
b225ffee
|
Fantič
|
import { IMAGE_URL } from "../../api/constants"
|
8 |
b88520f8
|
Fantič
|
|
9 |
|
|
interface ItemDetailProps {
|
10 |
|
|
item: Item,
|
11 |
852de08e
|
Fantič
|
itemLoading: boolean,
|
12 |
|
|
notes: Note[],
|
13 |
|
|
notesLoading: boolean
|
14 |
b88520f8
|
Fantič
|
}
|
15 |
|
|
|
16 |
|
|
const ItemDetail = (props: { item: Item }) => {
|
17 |
|
|
const item = props.item;
|
18 |
852de08e
|
Fantič
|
|
19 |
b88520f8
|
Fantič
|
return (
|
20 |
091dec61
|
Fantič
|
<ScrollView flex="1">
|
21 |
|
|
<Box width="90%" marginLeft="5%">
|
22 |
|
|
{
|
23 |
|
|
item && (
|
24 |
852de08e
|
Fantič
|
<VStack>
|
25 |
091dec61
|
Fantič
|
<HStack marginTop="5%">
|
26 |
|
|
<VStack width="75%">
|
27 |
|
|
<Text>
|
28 |
|
|
{item.authorDisplayName ? item.authorDisplayName : item.authorName}
|
29 |
|
|
</Text>
|
30 |
|
|
<Heading size="sm">
|
31 |
|
|
{item.workName}
|
32 |
|
|
</Heading>
|
33 |
|
|
|
34 |
|
|
</VStack>
|
35 |
|
|
<Box width="25%">
|
36 |
|
|
<Button variant="outline" size="md">
|
37 |
|
|
{item.concordances[0].id}
|
38 |
|
|
</Button>
|
39 |
|
|
</Box>
|
40 |
|
|
</HStack>
|
41 |
|
|
<Card shadow="1" marginTop="5%">
|
42 |
|
|
{item.inventoryItem &&
|
43 |
|
|
<VStack>
|
44 |
|
|
<Text italic>
|
45 |
|
|
<Text color="light.500">Inventory item: </Text>
|
46 |
|
|
{item.inventoryItem}
|
47 |
|
|
</Text>
|
48 |
|
|
<Text italic marginTop="2.5%">
|
49 |
|
|
{item.searchSubjects.map((subject, index) => (
|
50 |
|
|
index < item.searchSubjects.length -1 ? (subject + ", ") : (subject)
|
51 |
|
|
))}
|
52 |
|
|
</Text>
|
53 |
|
|
</VStack>}
|
54 |
|
|
</Card>
|
55 |
|
|
{item.fullView && item.imageUrl && (
|
56 |
|
|
<Center background="primary.100" marginTop="5%">
|
57 |
|
|
<Text>Resembling object</Text>
|
58 |
b225ffee
|
Fantič
|
<Image size={250} alt="image" source={{ uri: IMAGE_URL + "/" + item.imageUrl }} />
|
59 |
091dec61
|
Fantič
|
</Center>)}
|
60 |
|
|
{item.fullView && (
|
61 |
|
|
<Card shadow="1" marginTop="5%" marginBottom="5%">
|
62 |
|
|
{item.authorName &&
|
63 |
|
|
<HStack>
|
64 |
191f2cc7
|
Fantič
|
<Text italic marginTop="2.5%">
|
65 |
091dec61
|
Fantič
|
<Text color="light.500">Author name: </Text>
|
66 |
|
|
{item.authorName}
|
67 |
|
|
</Text>
|
68 |
|
|
</HStack>}
|
69 |
|
|
{item.title &&
|
70 |
|
|
<HStack>
|
71 |
191f2cc7
|
Fantič
|
<Text italic marginTop="2.5%">
|
72 |
091dec61
|
Fantič
|
<Text color="light.500">Title: </Text>
|
73 |
|
|
{item.title}
|
74 |
|
|
</Text>
|
75 |
|
|
</HStack>}
|
76 |
|
|
{item.institution &&
|
77 |
|
|
<HStack>
|
78 |
191f2cc7
|
Fantič
|
<Text italic marginTop="2.5%">
|
79 |
091dec61
|
Fantič
|
<Text color="light.500">Institution: </Text>
|
80 |
|
|
{item.institution.name}, Inv. No. {item.institution.inventoryNumber}, {item.institution.city} {"(" + item.institution.country + ")"}
|
81 |
|
|
</Text>
|
82 |
|
|
</HStack>}
|
83 |
|
|
{item.repository &&
|
84 |
|
|
<HStack>
|
85 |
191f2cc7
|
Fantič
|
<Text italic marginTop="2.5%">
|
86 |
091dec61
|
Fantič
|
<Text color="light.500">Repository: </Text>
|
87 |
|
|
{item.repository}
|
88 |
|
|
</Text>
|
89 |
|
|
</HStack>}
|
90 |
|
|
{item.provenance &&
|
91 |
|
|
<HStack>
|
92 |
191f2cc7
|
Fantič
|
<Text italic marginTop="2.5%">
|
93 |
091dec61
|
Fantič
|
<Text color="light.500">Provenance: </Text>
|
94 |
|
|
{item.provenance}
|
95 |
|
|
</Text>
|
96 |
|
|
</HStack>}
|
97 |
|
|
{item.description &&
|
98 |
|
|
<HStack>
|
99 |
191f2cc7
|
Fantič
|
<Text italic marginTop ="2.5%">
|
100 |
091dec61
|
Fantič
|
<Text color="light.500">Description: </Text>
|
101 |
|
|
{item.description}
|
102 |
|
|
</Text>
|
103 |
|
|
</HStack>}
|
104 |
|
|
</Card>)}
|
105 |
852de08e
|
Fantič
|
</VStack>
|
106 |
091dec61
|
Fantič
|
)
|
107 |
|
|
}
|
108 |
|
|
</Box>
|
109 |
|
|
</ScrollView>
|
110 |
b88520f8
|
Fantič
|
);
|
111 |
|
|
}
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
const ItemView = (props: ItemDetailProps) => {
|
116 |
|
|
|
117 |
|
|
// item shown / note shown
|
118 |
|
|
const [itemShown, setItemShown] = React.useState(true);
|
119 |
|
|
|
120 |
091dec61
|
Fantič
|
const { itemLoading, notesLoading } = props;
|
121 |
852de08e
|
Fantič
|
|
122 |
b88520f8
|
Fantič
|
const handleItemClick = () => {
|
123 |
|
|
setItemShown(true);
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
const handleNotesClick = () => {
|
127 |
|
|
setItemShown(false);
|
128 |
|
|
}
|
129 |
|
|
|
130 |
|
|
return (
|
131 |
852de08e
|
Fantič
|
<Box display="flex" flex={1} flexDirection="column" justifyContent="space-between">
|
132 |
b88520f8
|
Fantič
|
{itemShown ? (
|
133 |
091dec61
|
Fantič
|
itemLoading ?
|
134 |
|
|
<LoadingBox text="Item loading" />
|
135 |
|
|
:
|
136 |
|
|
<ItemDetail item={props.item} />
|
137 |
b88520f8
|
Fantič
|
) : (
|
138 |
091dec61
|
Fantič
|
notesLoading ?
|
139 |
|
|
<LoadingBox text="Notes loading" />
|
140 |
|
|
:
|
141 |
b225ffee
|
Fantič
|
<NotesListView notes={props.notes} handleDelete={() => console.log("TODO handle delete")} handleEdit={() => console.log("TODO handle edit")} handleReply={() => console.log("TODO handle reply")}/>
|
142 |
b88520f8
|
Fantič
|
)}
|
143 |
852de08e
|
Fantič
|
|
144 |
|
|
{/* item notes switch tab */}
|
145 |
|
|
<HStack alignItems="center">
|
146 |
091dec61
|
Fantič
|
<Button
|
147 |
852de08e
|
Fantič
|
variant={itemShown ? "subtle" : "outline"}
|
148 |
|
|
w="50%"
|
149 |
b88520f8
|
Fantič
|
onPress={handleItemClick}
|
150 |
|
|
>
|
151 |
|
|
Item
|
152 |
|
|
</Button>
|
153 |
091dec61
|
Fantič
|
<Button
|
154 |
852de08e
|
Fantič
|
variant={itemShown ? "outline" : "subtle"}
|
155 |
|
|
w="50%"
|
156 |
b88520f8
|
Fantič
|
onPress={handleNotesClick}
|
157 |
|
|
>
|
158 |
|
|
Notes
|
159 |
|
|
</Button>
|
160 |
|
|
</HStack>
|
161 |
852de08e
|
Fantič
|
</Box>
|
162 |
b88520f8
|
Fantič
|
)
|
163 |
|
|
}
|
164 |
|
|
|
165 |
|
|
export default ItemView
|