Skip to content

Commit

Permalink
dao nav based on env rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
abrzezinski94 committed Oct 12, 2021
1 parent 50855fd commit 06163a9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 28 deletions.
11 changes: 4 additions & 7 deletions components/OrganzationsBackNav.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import React from 'react'
import useRealm from '../hooks/useRealm'
import { useRouter } from 'next/router'
import { GlobeAltIcon } from '@heroicons/react/outline'
import { ArrowLeftIcon } from '@heroicons/react/solid'
import Link from 'next/link'
import { TwitterIcon } from '../components/icons'
import useRealmContext from '../hooks/useRealmContext'

const OrganzationsBackNav = () => {
const router = useRouter()
const { generateUrlWithClusterParam } = useRealmContext()
const { generateUrlWithClusterParam, isOneRealmMode } = useRealmContext()
const { realm, realmInfo } = useRealm()

const realmName = realmInfo?.displayName ?? realm?.info?.name
const hideBackNav = !router.asPath.includes('dao') // only hide backnav when on default realm
const backNavLink = generateUrlWithClusterParam('/realms')
const isBackNavVisibile = !isOneRealmMode // only hide backnav when on default realm

return (
<div className="pb-4">
{hideBackNav ? (
<Link href={backNavLink}>
{isBackNavVisibile ? (
<Link href={generateUrlWithClusterParam('/realms')}>
<a className="default-transition flex items-center mb-6 text-fgd-3 text-sm transition-all hover:text-fgd-1">
<ArrowLeftIcon className="h-4 w-4 mr-1 text-primary-light" />
Back
Expand Down
8 changes: 2 additions & 6 deletions components/ProposalCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const StyledCardWrapepr = styled.div`

const ProposalCard = ({ id, proposal }: ProposalCardProps) => {
const { symbol } = useRealm()
const { urlContext, generateUrlWithClusterParam } = useRealmContext()
const { generateUrlWithClusterParam } = useRealmContext()
const {
yesVoteProgress,
relativeNoVotes,
Expand All @@ -43,11 +43,7 @@ const ProposalCard = ({ id, proposal }: ProposalCardProps) => {

return (
<div>
<Link
href={generateUrlWithClusterParam(
`/${urlContext}/${symbol}/proposal/${id}`
)}
>
<Link href={generateUrlWithClusterParam(`/dao/${symbol}/proposal/${id}`)}>
<a>
<StyledCardWrapepr className="bg-bkg-2 border border-bkg-3 default-transition rounded-lg hover:bg-bkg-3">
<div className="px-6 py-4">
Expand Down
5 changes: 3 additions & 2 deletions hooks/useRealmContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { EndpointTypes } from '../models/types'
export default function useRealmContext() {
const router = useRouter()
const { cluster } = router.query
const { REALM } = process.env

const isOneRealmMode = REALM
const endpoint = cluster ? (cluster as EndpointTypes) : 'mainnet'
const hasClusterOption = endpoint !== 'mainnet'
const generateUrlWithClusterParam = (url) => {
Expand All @@ -15,9 +17,8 @@ export default function useRealmContext() {
return url
}

const urlContext = router.asPath.includes('realm') ? 'realm' : 'dao'
return {
urlContext,
isOneRealmMode,
generateUrlWithClusterParam,
}
}
8 changes: 0 additions & 8 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,4 @@ module.exports = withTM({
env: {
REALM: process.env.REALM,
},
async rewrites() {
return [
{
source: '/realm/:symbol*',
destination: '/dao/:symbol*',
},
]
},
})
6 changes: 2 additions & 4 deletions pages/dao/[symbol]/proposal/[pk].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { option } from '../../../../tools/core/option'
import useRealmContext from '../../../../hooks/useRealmContext'

const Proposal = () => {
const { urlContext, generateUrlWithClusterParam } = useRealmContext()
const { generateUrlWithClusterParam } = useRealmContext()
const { symbol } = useRealm()
const { proposal, description, instructions } = useProposal()
const {
Expand All @@ -43,9 +43,7 @@ const Proposal = () => {
<div className="bg-bkg-2 border border-bkg-3 rounded-lg p-6 col-span-8 space-y-3">
{proposal ? (
<>
<Link
href={generateUrlWithClusterParam(`/${urlContext}/${symbol}/`)}
>
<Link href={generateUrlWithClusterParam(`/dao/${symbol}/`)}>
<a className="flex items-center text-fgd-3 text-sm transition-all hover:text-fgd-1">
<ArrowLeftIcon className="h-4 w-4 mr-1 text-primary-light" />
Back
Expand Down
2 changes: 1 addition & 1 deletion pages/realms/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const Realms = () => {
// }, [search, realms])

const goToRealm = ({ symbol }) => {
const url = generateUrlWithClusterParam(`/realm/${symbol}`)
const url = generateUrlWithClusterParam(`/dao/${symbol}`)
router.push(url)
}

Expand Down

0 comments on commit 06163a9

Please sign in to comment.