Skip to content

Commit f03a185

Browse files
committed
Fix to and from times on torch card
1 parent f95d23a commit f03a185

File tree

2 files changed

+40
-27
lines changed

2 files changed

+40
-27
lines changed

app/[locale]/10years/_components/TorchHistoryCard.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface TorchHistoryCardProps {
1919
avatar: string
2020
twitter: string
2121
from: number
22-
to: number
22+
to?: number
2323
transactionHash: string
2424
className?: string
2525
isCurrentHolder?: boolean
@@ -78,7 +78,8 @@ const TorchHistoryCard: React.FC<TorchHistoryCardProps> = ({
7878
{!isPlaceholder && (
7979
<>
8080
<div className="text-xs text-gray-500">
81-
From {formatDate(from)} to {formatDate(to)}
81+
From {formatDate(from)}
82+
{to !== undefined ? ` to ${formatDate(to)}` : " to present"}
8283
</div>
8384
<BaseLink
8485
href={getTxEtherscanUrl(transactionHash)}

app/[locale]/10years/_components/TorchHistorySwiper/index.tsx

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -75,31 +75,43 @@ const TorchHistorySwiper = ({
7575
modules={[EffectCoverflow, Navigation]}
7676
className="w-full"
7777
>
78-
{allCards.map((card, idx) => (
79-
<SwiperSlide
80-
key={idx}
81-
className="flex !min-h-[400px] !w-60 justify-center"
82-
>
83-
<TorchHistoryCard
84-
className="!min-h-[400px]"
85-
name={card.name}
86-
role={card.role}
87-
avatar={
88-
card.isPlaceholder
89-
? "/images/10-year-anniversary/torch-cover.webp"
90-
: getAvatarImage(card)
91-
}
92-
twitter={card.twitter}
93-
from={card.event.timestamp}
94-
to={card.event.timestamp}
95-
transactionHash={card.event.transactionHash}
96-
isCurrentHolder={
97-
!card.isPlaceholder && card.address === currentHolderAddress
98-
}
99-
isPlaceholder={card.isPlaceholder}
100-
/>
101-
</SwiperSlide>
102-
))}
78+
{allCards.map((card, idx) => {
79+
// For past holders, "to" is the timestamp of the next holder's event.
80+
// For the current holder, "to" is undefined to signify "present".
81+
// For placeholders, "to" is the same as "from" (0).
82+
const toTimestamp =
83+
!card.isPlaceholder && idx < holders.length - 1
84+
? holders[idx + 1].event.timestamp
85+
: card.isPlaceholder
86+
? card.event.timestamp
87+
: undefined
88+
89+
return (
90+
<SwiperSlide
91+
key={idx}
92+
className="flex !min-h-[400px] !w-60 justify-center"
93+
>
94+
<TorchHistoryCard
95+
className="!min-h-[400px]"
96+
name={card.name}
97+
role={card.role}
98+
avatar={
99+
card.isPlaceholder
100+
? "/images/10-year-anniversary/torch-cover.webp"
101+
: getAvatarImage(card)
102+
}
103+
twitter={card.twitter}
104+
from={card.event.timestamp}
105+
to={toTimestamp}
106+
transactionHash={card.event.transactionHash}
107+
isCurrentHolder={
108+
!card.isPlaceholder && card.address === currentHolderAddress
109+
}
110+
isPlaceholder={card.isPlaceholder}
111+
/>
112+
</SwiperSlide>
113+
)
114+
})}
103115
<SwiperNavigation className="mt-8" />
104116
</Swiper>
105117
</SwiperContainer>

0 commit comments

Comments
 (0)