Skip to content

Commit 9453479

Browse files
committed
Fix ssr related crash on collection page
1 parent d188b9f commit 9453479

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

pages/[chain]/collection/[contract].tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const CollectionPage: NextPage<Props> = ({ id, ssr }) => {
106106
const scrollRef = useRef<HTMLDivElement | null>(null)
107107
const collectionChain =
108108
supportedChains.find(
109-
(chain) => router.query?.chain === chain.routePrefix
109+
(chain) => router.query?.chain === chain.routePrefix,
110110
) || DefaultChain
111111

112112
const scrollToTop = () => {
@@ -130,7 +130,7 @@ const CollectionPage: NextPage<Props> = ({ id, ssr }) => {
130130
let collection = collections && collections[0]
131131

132132
const mintData = collection?.mintStages?.find(
133-
(stage) => stage.kind === 'public'
133+
(stage) => stage.kind === 'public',
134134
)
135135

136136
const mintPriceDecimal = mintData?.price?.amount?.decimal
@@ -213,7 +213,7 @@ const CollectionPage: NextPage<Props> = ({ id, ssr }) => {
213213
? reservoirEvent.data?.market?.floorAskNormalized?.price?.amount?.native
214214
: reservoirEvent.data?.market?.floorAsk?.price?.amount?.native
215215
const tokenIndex = tokens.findIndex(
216-
(token) => token.token?.tokenId === reservoirEvent?.data.token.tokenId
216+
(token) => token.token?.tokenId === reservoirEvent?.data.token.tokenId,
217217
)
218218
const token = tokenIndex > -1 ? tokens[tokenIndex] : null
219219
if (token) {
@@ -226,7 +226,7 @@ const CollectionPage: NextPage<Props> = ({ id, ssr }) => {
226226
if (!price) {
227227
if (token) {
228228
const endOfListingsIndex = tokens.findIndex(
229-
(token) => !token.market?.floorAsk?.price?.amount?.native
229+
(token) => !token.market?.floorAsk?.price?.amount?.native,
230230
)
231231
if (endOfListingsIndex === -1) {
232232
hasChange = true
@@ -235,8 +235,8 @@ const CollectionPage: NextPage<Props> = ({ id, ssr }) => {
235235
sortBy === 'rarity'
236236
? tokenIndex
237237
: endOfListingsIndex > -1
238-
? endOfListingsIndex
239-
: 0
238+
? endOfListingsIndex
239+
: 0
240240
newTokens.splice(newTokenIndex, 0, {
241241
...token,
242242
market: {
@@ -301,7 +301,7 @@ const CollectionPage: NextPage<Props> = ({ id, ssr }) => {
301301
tokens: newTokens,
302302
},
303303
],
304-
}
304+
},
305305
)
306306
}
307307
},
@@ -315,7 +315,7 @@ const CollectionPage: NextPage<Props> = ({ id, ssr }) => {
315315
}
316316
return attributesData.data
317317
?.filter(
318-
(attribute) => attribute.kind != 'number' && attribute.kind != 'range'
318+
(attribute) => attribute.kind != 'number' && attribute.kind != 'range',
319319
)
320320
.sort((a, b) => a.key.localeCompare(b.key))
321321
}, [attributesData.data])
@@ -328,7 +328,7 @@ const CollectionPage: NextPage<Props> = ({ id, ssr }) => {
328328
collection?.tokenCount &&
329329
+collection.tokenCount >= 2 &&
330330
attributes &&
331-
attributes?.length >= 2
331+
attributes?.length >= 2,
332332
)
333333

334334
const hasSecurityConfig =
@@ -365,17 +365,17 @@ const CollectionPage: NextPage<Props> = ({ id, ssr }) => {
365365
<meta property="fc:frame" content="vNext" />
366366
<meta
367367
property="fc:frame:image"
368-
content={collection.image || collection.banner}
368+
content={collection?.image || collection?.banner}
369369
/>
370370
<meta property="fc:frame:image:aspect_ratio" content="1:1" />
371371
<meta property="fc:frame:button:1" content="Mint" />
372372
<meta property="fc:frame:button:1:action" content="mint" />
373373
<meta
374374
property="fc:frame:button:1:target"
375-
content={`eip155:${collection.chainId}:${collection.primaryContract}`}
375+
content={`eip155:${collection?.chainId}:${collection?.primaryContract}`}
376376
/>
377377

378-
{collection.floorAsk?.price?.amount?.native && (
378+
{collection?.floorAsk?.price?.amount?.native && (
379379
<>
380380
<meta
381381
property="fc:frame:button:2"
@@ -973,7 +973,7 @@ export const getServerSideProps: GetServerSideProps<{
973973
const collectionsPromise = fetcher(
974974
`${reservoirBaseUrl}/collections/v7`,
975975
collectionQuery,
976-
headers
976+
headers,
977977
)
978978

979979
let tokensQuery: paths['/tokens/v6']['get']['parameters']['query'] = {
@@ -991,7 +991,7 @@ export const getServerSideProps: GetServerSideProps<{
991991
const tokensPromise = fetcher(
992992
`${reservoirBaseUrl}/tokens/v6`,
993993
tokensQuery,
994-
headers
994+
headers,
995995
)
996996

997997
const promises = await Promise.allSettled([
@@ -1009,12 +1009,12 @@ export const getServerSideProps: GetServerSideProps<{
10091009

10101010
const hasAttributes =
10111011
tokens?.tokens?.some(
1012-
(token) => (token?.token?.attributes?.length || 0) > 0
1012+
(token) => (token?.token?.attributes?.length || 0) > 0,
10131013
) || false
10141014

10151015
res.setHeader(
10161016
'Cache-Control',
1017-
'public, s-maxage=30, stale-while-revalidate=60'
1017+
'public, s-maxage=30, stale-while-revalidate=60',
10181018
)
10191019

10201020
return {

0 commit comments

Comments
 (0)