Skip to content

Commit c4e5605

Browse files
authored
feat: add not available status to partner offer notifications (artsy#9738)
1 parent 616c37a commit c4e5605

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

src/app/Scenes/Activity/ActivityItem.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ export const ActivityItem: React.FC<ActivityItemProps> = (props) => {
6969
<Text variant="sm-display">{item.message}</Text>
7070
)}
7171

72-
{shouldDisplayExpiresInTimer(item) && (
73-
<ExpiresInTimer expiresAt={item?.item?.expiresAt ?? ""} />
74-
)}
72+
{shouldDisplayExpiresInTimer(item) && <ExpiresInTimer item={item} />}
7573

7674
<Spacer y={1} />
7775

@@ -128,6 +126,7 @@ const activityItemFragment = graphql`
128126
129127
item {
130128
... on PartnerOfferCreatedNotificationItem {
129+
available
131130
expiresAt
132131
}
133132
}

src/app/Scenes/Activity/components/ExpiresInTimer.tsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,22 @@ import { Stopwatch, Flex, Text } from "@artsy/palette-mobile"
22
import { ActivityItem_item$data } from "__generated__/ActivityItem_item.graphql"
33
import { formattedTimeLeft } from "app/Scenes/Activity/utils/formattedTimeLeft"
44
import { Time, getTimer } from "app/utils/getTimer"
5-
import { useEffect, useRef, useState } from "react"
5+
import { FC, useEffect, useRef, useState } from "react"
66

77
const INTERVAL = 1000
88

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+
1021
const intervalId = useRef<ReturnType<typeof setInterval> | null>(null)
1122

1223
const [time, setTime] = useState<Time>(getTimer(expiresAt)["time"])
@@ -25,10 +36,22 @@ export const ExpiresInTimer: React.FC<{ expiresAt: string }> = ({ expiresAt }) =
2536
}
2637
}, [])
2738

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+
2851
if (hasEnded) {
2952
return (
3053
<Flex flexDirection="row" alignItems="center">
31-
<Stopwatch fill="red100" height={15} width={15} mr="2px" ml="-2px" />
54+
<WatchIcon />
3255

3356
<Text variant="xs" color="red100">
3457
Expired

0 commit comments

Comments
 (0)