Skip to content

Commit

Permalink
Add easter egg (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
wirednkod authored Sep 20, 2024
1 parent dc08011 commit 202db63
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions src/components/RedirectByName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,27 @@ export const RedirectByName = () => {
const [address, setAddress] = useState('')
const { selectNetwork } = useNetwork()

const [redirectionNetwork, setRedirectionNetwork] = useState<string>('')

useEffect(() => {
const netw =
network === 'porkydot'
? 'polkadot'
: network === 'kus000mba'
? 'kusama'
: network || ''
setRedirectionNetwork(netw)
}, [network])

useEffect(() => {
if (!network || !isSupportedNetwork(network)) {
if (!redirectionNetwork || !isSupportedNetwork(redirectionNetwork)) {
setIsDelegateMissing(true)

return
}

selectNetwork(network)
}, [network, selectNetwork])
selectNetwork(redirectionNetwork)
}, [redirectionNetwork, selectNetwork])

useEffect(() => {
if (!name) {
Expand All @@ -36,10 +48,22 @@ export const RedirectByName = () => {
} else {
setAddress(delegate.address)
}
}, [getDelegateByName, isDelegateLoading, name, network, selectNetwork])
}, [
getDelegateByName,
isDelegateLoading,
name,
redirectionNetwork,
selectNetwork,
])

if (address && !!network && isSupportedNetwork(network)) {
return <Navigate to={`/delegate/${address}?network=${network}`} />
if (
address &&
!!redirectionNetwork &&
isSupportedNetwork(redirectionNetwork)
) {
return (
<Navigate to={`/delegate/${address}?network=${redirectionNetwork}`} />
)
}

if (!isDelegateMissing) {
Expand All @@ -50,7 +74,7 @@ export const RedirectByName = () => {
<div className="flex h-full w-full items-center justify-center">
Delegate not found for name:{' '}
<span className="mx-2 font-bold">{name}</span> and network:{' '}
<span className="mx-2 font-bold">{network}</span>
<span className="mx-2 font-bold">{redirectionNetwork}</span>
</div>
)
}

0 comments on commit 202db63

Please sign in to comment.