Skip to content

Commit

Permalink
Merge pull request #448 from ourzora/add-referral-to-redirect
Browse files Browse the repository at this point in the history
Add referral query param to token redirect
  • Loading branch information
neokry authored Mar 11, 2024
2 parents 3c9156e + e1f5c71 commit a2d97a8
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions apps/web/src/pages/dao/[network]/[token]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
const collectionAddress = context?.params?.token as AddressType
const network = context?.params?.network
const tab = context?.query?.tab as string
const referral = context?.query?.referral as string

const chain = PUBLIC_DEFAULT_CHAINS.find((x) => x.slug === network)

Expand Down Expand Up @@ -164,11 +165,22 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
}
}

if (!tab && !referral) {
return {
redirect: {
destination: `/dao/${network}/${collectionAddress}/${latestTokenId}`,
permanent: false,
},
}
}

const params = new URLSearchParams()
if (tab) params.set('tab', tab)
if (referral) params.set('referral', referral)

return {
redirect: {
destination: `/dao/${network}/${collectionAddress}/${latestTokenId}${
tab ? `?tab=${tab}` : ''
}`,
destination: `/dao/${network}/${collectionAddress}/${latestTokenId}?${params.toString()}`,
permanent: false,
},
}
Expand Down

0 comments on commit a2d97a8

Please sign in to comment.