Skip to content

Commit

Permalink
feat: add not available status to partner offer notifications (artsy#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nickskalkin authored Jan 18, 2024
1 parent 616c37a commit c4e5605
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/app/Scenes/Activity/ActivityItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ export const ActivityItem: React.FC<ActivityItemProps> = (props) => {
<Text variant="sm-display">{item.message}</Text>
)}

{shouldDisplayExpiresInTimer(item) && (
<ExpiresInTimer expiresAt={item?.item?.expiresAt ?? ""} />
)}
{shouldDisplayExpiresInTimer(item) && <ExpiresInTimer item={item} />}

<Spacer y={1} />

Expand Down Expand Up @@ -128,6 +126,7 @@ const activityItemFragment = graphql`
item {
... on PartnerOfferCreatedNotificationItem {
available
expiresAt
}
}
Expand Down
29 changes: 26 additions & 3 deletions src/app/Scenes/Activity/components/ExpiresInTimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@ import { Stopwatch, Flex, Text } from "@artsy/palette-mobile"
import { ActivityItem_item$data } from "__generated__/ActivityItem_item.graphql"
import { formattedTimeLeft } from "app/Scenes/Activity/utils/formattedTimeLeft"
import { Time, getTimer } from "app/utils/getTimer"
import { useEffect, useRef, useState } from "react"
import { FC, useEffect, useRef, useState } from "react"

const INTERVAL = 1000

export const ExpiresInTimer: React.FC<{ expiresAt: string }> = ({ expiresAt }) => {
interface ExpiresInTimerProps {
item: ActivityItem_item$data
}

const WatchIcon: FC<{ fill?: string }> = ({ fill = "red100" }) => {
return <Stopwatch fill={fill} height={15} width={15} mr="2px" ml="-2px" />
}

export const ExpiresInTimer: FC<ExpiresInTimerProps> = ({ item }) => {
const expiresAt = item?.item?.expiresAt ?? ""
const available = item?.item?.available ?? false

const intervalId = useRef<ReturnType<typeof setInterval> | null>(null)

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

if (!available) {
return (
<Flex flexDirection="row" alignItems="center">
<WatchIcon />

<Text variant="xs" color="red100">
No longer available
</Text>
</Flex>
)
}

if (hasEnded) {
return (
<Flex flexDirection="row" alignItems="center">
<Stopwatch fill="red100" height={15} width={15} mr="2px" ml="-2px" />
<WatchIcon />

<Text variant="xs" color="red100">
Expired
Expand Down

0 comments on commit c4e5605

Please sign in to comment.