Retain contract address while switching between link tabs

This commit is contained in:
Serkan Reis
2023-11-20 23:16:16 +03:00
parent 3e052e6e1e
commit 4d53d498d7
21 changed files with 66 additions and 1 deletions
+6 -1
View File
@@ -1,5 +1,6 @@
import clsx from 'clsx'
import { Anchor } from 'components/Anchor'
import { useRouter } from 'next/router'
export interface LinkTabProps {
title: string
@@ -11,6 +12,10 @@ export interface LinkTabProps {
export const LinkTab = (props: LinkTabProps) => {
const { title, description, href, isActive } = props
// get contract address from the router
const router = useRouter()
const { contractAddress } = router.query
return (
<Anchor
className={clsx(
@@ -19,7 +24,7 @@ export const LinkTab = (props: LinkTabProps) => {
isActive ? 'border-plumbus' : 'border-transparent',
isActive ? 'bg-plumbus/5 hover:bg-plumbus/10' : 'hover:bg-white/5',
)}
href={href}
href={href + (contractAddress ? `?contractAddress=${contractAddress as string}` : '')}
>
<h4 className="font-bold">{title}</h4>
<span className="text-sm text-white/80 line-clamp-2">{description}</span>