@@ -2,11 +2,22 @@ import { Stopwatch, Flex, Text } from "@artsy/palette-mobile"
2
2
import { ActivityItem_item$data } from "__generated__/ActivityItem_item.graphql"
3
3
import { formattedTimeLeft } from "app/Scenes/Activity/utils/formattedTimeLeft"
4
4
import { Time , getTimer } from "app/utils/getTimer"
5
- import { useEffect , useRef , useState } from "react"
5
+ import { FC , useEffect , useRef , useState } from "react"
6
6
7
7
const INTERVAL = 1000
8
8
9
- export const ExpiresInTimer : React . FC < { expiresAt : string } > = ( { expiresAt } ) => {
9
+ interface ExpiresInTimerProps {
10
+ item : ActivityItem_item$data
11
+ }
12
+
13
+ const WatchIcon : FC < { fill ?: string } > = ( { fill = "red100" } ) => {
14
+ return < Stopwatch fill = { fill } height = { 15 } width = { 15 } mr = "2px" ml = "-2px" />
15
+ }
16
+
17
+ export const ExpiresInTimer : FC < ExpiresInTimerProps > = ( { item } ) => {
18
+ const expiresAt = item ?. item ?. expiresAt ?? ""
19
+ const available = item ?. item ?. available ?? false
20
+
10
21
const intervalId = useRef < ReturnType < typeof setInterval > | null > ( null )
11
22
12
23
const [ time , setTime ] = useState < Time > ( getTimer ( expiresAt ) [ "time" ] )
@@ -25,10 +36,22 @@ export const ExpiresInTimer: React.FC<{ expiresAt: string }> = ({ expiresAt }) =
25
36
}
26
37
} , [ ] )
27
38
39
+ if ( ! available ) {
40
+ return (
41
+ < Flex flexDirection = "row" alignItems = "center" >
42
+ < WatchIcon />
43
+
44
+ < Text variant = "xs" color = "red100" >
45
+ No longer available
46
+ </ Text >
47
+ </ Flex >
48
+ )
49
+ }
50
+
28
51
if ( hasEnded ) {
29
52
return (
30
53
< Flex flexDirection = "row" alignItems = "center" >
31
- < Stopwatch fill = "red100" height = { 15 } width = { 15 } mr = "2px" ml = "-2px" />
54
+ < WatchIcon />
32
55
33
56
< Text variant = "xs" color = "red100" >
34
57
Expired
0 commit comments