1
|
import { Box, Center, Text, VStack } from "native-base"
|
2
|
import { useEffect, useState } from "react"
|
3
|
import { log } from "../../logging/logger"
|
4
|
|
5
|
interface ItemPreviewMissingImageProps {
|
6
|
inventoryLabel: string
|
7
|
w?: number
|
8
|
h?: number
|
9
|
}
|
10
|
|
11
|
const DEFAULT_W = 65
|
12
|
const DEFAULT_H = 65
|
13
|
|
14
|
export const ItemPreviewMissingImage = (props: ItemPreviewMissingImageProps) => {
|
15
|
const [firstPart, setFirstPart] = useState("")
|
16
|
const [secondPart, setSecondPart] = useState("")
|
17
|
|
18
|
useEffect(() => {
|
19
|
setFirstPart(props.inventoryLabel.slice(0, props.inventoryLabel.indexOf(" ")))
|
20
|
setSecondPart(props.inventoryLabel.slice(props.inventoryLabel.indexOf(" ") + 1))
|
21
|
log.debug("ItemPreviewMissingImage", "inventoryLabel", props.inventoryLabel)
|
22
|
log.debug("ItemPreviewMissingImage", "firstPart", firstPart)
|
23
|
log.debug("ItemPreviewMissingImage", "secondPart", secondPart)
|
24
|
}, [props.inventoryLabel])
|
25
|
|
26
|
return (
|
27
|
<Center>
|
28
|
<Box
|
29
|
bg="primary.100"
|
30
|
w={props.w ? props.w : DEFAULT_W}
|
31
|
h={props.h ? props.h : DEFAULT_H}
|
32
|
borderColor={"primary.700"}
|
33
|
borderWidth={4}
|
34
|
alignItems="center"
|
35
|
justifyContent="center"
|
36
|
>
|
37
|
<VStack space={0}>
|
38
|
<Text
|
39
|
fontSize="sm"
|
40
|
color="black"
|
41
|
textAlign={"center"}
|
42
|
bold
|
43
|
noOfLines={1}
|
44
|
>
|
45
|
{ firstPart }
|
46
|
</Text>
|
47
|
<Text
|
48
|
fontSize="xs"
|
49
|
color="black"
|
50
|
textAlign={"center"}
|
51
|
>
|
52
|
{ secondPart }
|
53
|
</Text>
|
54
|
</VStack>
|
55
|
</Box>
|
56
|
</Center>
|
57
|
)
|
58
|
}
|