diff --git a/packages/stateful/components/dao/CreateDaoForm.tsx b/packages/stateful/components/dao/CreateDaoForm.tsx index ea9ef92f7..2396a3e0f 100644 --- a/packages/stateful/components/dao/CreateDaoForm.tsx +++ b/packages/stateful/components/dao/CreateDaoForm.tsx @@ -25,6 +25,7 @@ import { TooltipInfoIcon, useAppContext, useCachedLoadable, + useDaoInfoContextIfAvailable, useDaoNavHelpers, useSupportedChainContext, useThemeContext, @@ -146,6 +147,7 @@ export const InnerCreateDaoForm = ({ initialPageIndex = 0, }: CreateDaoFormProps) => { const { t } = useTranslation() + const daoInfo = useDaoInfoContextIfAvailable() const chainContext = useSupportedChainContext() const { @@ -733,6 +735,7 @@ export const InnerCreateDaoForm = ({ } : undefined, current: makingSubDao ? t('title.newSubDao') : t('title.newDao'), + daoInfo, }} centerNode={ !makingSubDao && ( diff --git a/packages/stateful/components/dao/CreateDaoProposal.tsx b/packages/stateful/components/dao/CreateDaoProposal.tsx index 8fc7fe3bc..b17e0c953 100644 --- a/packages/stateful/components/dao/CreateDaoProposal.tsx +++ b/packages/stateful/components/dao/CreateDaoProposal.tsx @@ -379,6 +379,7 @@ const InnerCreateDaoProposal = ({ sdaLabel: t('title.proposals'), }, current: t('title.createProposal'), + daoInfo, }} /> diff --git a/packages/stateful/components/dao/DaoProposal.tsx b/packages/stateful/components/dao/DaoProposal.tsx index 4ed3177d6..c27c6ea9b 100644 --- a/packages/stateful/components/dao/DaoProposal.tsx +++ b/packages/stateful/components/dao/DaoProposal.tsx @@ -45,7 +45,7 @@ interface InnerDaoProposalProps { const InnerDaoProposal = ({ proposalInfo }: InnerDaoProposalProps) => { const { t } = useTranslation() - const { coreAddress } = useDaoInfoContext() + const daoInfo = useDaoInfoContext() const { address } = useWallet() const proposalModuleAdapterContext = useProposalModuleAdapterContext() @@ -135,7 +135,9 @@ const InnerDaoProposal = ({ proposalInfo }: InnerDaoProposalProps) => { toast.loading(t('success.proposalExecuted')) // Manually revalidate DAO static props. - await fetch(`/api/revalidate?d=${coreAddress}&p=${proposalInfo.id}`) + await fetch( + `/api/revalidate?d=${daoInfo.coreAddress}&p=${proposalInfo.id}` + ) // Refresh entire app since any DAO config may have changed. window.location.reload() @@ -244,6 +246,7 @@ const InnerDaoProposal = ({ proposalInfo }: InnerDaoProposalProps) => { sdaLabel: t('title.proposals'), }, current: `${t('title.proposal')} ${proposalInfo.id}`, + daoInfo, }} rightNode={ canVote ? ( diff --git a/packages/stateful/components/gov/CreateGovProposal.tsx b/packages/stateful/components/gov/CreateGovProposal.tsx index aa7278b8a..e91291aaf 100644 --- a/packages/stateful/components/gov/CreateGovProposal.tsx +++ b/packages/stateful/components/gov/CreateGovProposal.tsx @@ -1,7 +1,11 @@ import { useRef } from 'react' import { useTranslation } from 'react-i18next' -import { CreateProposal, PageLoader } from '@dao-dao/stateless' +import { + CreateProposal, + PageLoader, + useDaoInfoContextIfAvailable, +} from '@dao-dao/stateless' import { DaoTabId } from '@dao-dao/types' import { GovActionsProvider } from '../../actions' @@ -11,6 +15,7 @@ import { NewGovProposal } from './NewGovProposal' export const CreateGovProposal = () => { const { t } = useTranslation() + const daoInfo = useDaoInfoContextIfAvailable() const clearRef = useRef(() => {}) const copyDraftLinkRef = useRef(() => {}) @@ -24,6 +29,7 @@ export const CreateGovProposal = () => { sdaLabel: t('title.proposals'), }, current: t('title.createProposal'), + daoInfo, }} /> diff --git a/packages/stateful/components/gov/GovProposal.tsx b/packages/stateful/components/gov/GovProposal.tsx index 3b0130266..952b0ce0c 100644 --- a/packages/stateful/components/gov/GovProposal.tsx +++ b/packages/stateful/components/gov/GovProposal.tsx @@ -14,6 +14,7 @@ import { ProposalNotFound, useCachedLoadingWithError, useChain, + useDaoInfoContextIfAvailable, } from '@dao-dao/stateless' import { BaseProposalVotesProps, @@ -47,6 +48,7 @@ type InnerGovProposalProps = { const InnerGovProposal = ({ proposal }: InnerGovProposalProps) => { const { t } = useTranslation() const { chain_id: chainId } = useChain() + const daoInfo = useDaoInfoContextIfAvailable() const proposalId = proposal.id.toString() const loadingProposal = useLoadingGovProposal(proposalId) @@ -114,6 +116,7 @@ const InnerGovProposal = ({ proposal }: InnerGovProposalProps) => { sdaLabel: t('title.proposals'), }, current: `${t('title.proposal')} ${proposalId}`, + daoInfo, }} rightNode={ proposal.proposal.status === diff --git a/packages/stateful/components/pages/DaoDappHome.tsx b/packages/stateful/components/pages/DaoDappHome.tsx index d328e73d3..e25fbaade 100644 --- a/packages/stateful/components/pages/DaoDappHome.tsx +++ b/packages/stateful/components/pages/DaoDappHome.tsx @@ -42,9 +42,8 @@ export const InnerDaoDappHome = ({ ...props }: InnerDaoDappHomeProps) => { const { t } = useTranslation() - const { getDaoPath, getDaoProposalPath, router } = useDaoNavHelpers() - const daoInfo = useDaoInfoContext() + const { getDaoPath, getDaoProposalPath, router } = useDaoNavHelpers() const { isFollowing, setFollowing, setUnfollowing, updatingFollowing } = useFollowingDaos() @@ -111,6 +110,7 @@ export const InnerDaoDappHome = ({ breadcrumbs={{ home: true, current: daoInfo.name, + daoInfo, }} rightNode={ <> diff --git a/packages/stateful/components/pages/DaoSdaHome.tsx b/packages/stateful/components/pages/DaoSdaHome.tsx index 470639370..75135eb5e 100644 --- a/packages/stateful/components/pages/DaoSdaHome.tsx +++ b/packages/stateful/components/pages/DaoSdaHome.tsx @@ -14,7 +14,7 @@ import { SuspenseLoader } from '../SuspenseLoader' export const DaoSdaHome = () => { const router = useRouter() - const { coreAddress } = useDaoInfoContext() + const daoInfo = useDaoInfoContext() const { getDaoPath } = useDaoNavHelpers() const loadingTabs = useDaoTabs() @@ -27,9 +27,9 @@ export const DaoSdaHome = () => { // Pre-fetch tabs. useEffect(() => { tabs?.forEach((tab) => { - router.prefetch(getDaoPath(coreAddress, tab.id)) + router.prefetch(getDaoPath(daoInfo.coreAddress, tab.id)) }) - }, [coreAddress, getDaoPath, router, tabs]) + }, [daoInfo.coreAddress, getDaoPath, router, tabs]) const slug = (router.query.slug || []) as string[] const checkedSlug = useRef(false) @@ -44,11 +44,11 @@ export const DaoSdaHome = () => { // If no slug, redirect to first tab. if (slug.length === 0) { - router.replace(getDaoPath(coreAddress, firstTabId), undefined, { + router.replace(getDaoPath(daoInfo.coreAddress, firstTabId), undefined, { shallow: true, }) } - }, [coreAddress, getDaoPath, router, slug.length, firstTabId]) + }, [daoInfo.coreAddress, getDaoPath, router, slug.length, firstTabId]) const selectedTabId = slug.length > 0 && tabs?.some(({ id }) => id === slug[0]) @@ -65,6 +65,7 @@ export const DaoSdaHome = () => { breadcrumbs={{ home: true, current: activeTab?.label, + daoInfo, }} /> diff --git a/packages/stateless/components/layout/Breadcrumbs.tsx b/packages/stateless/components/layout/Breadcrumbs.tsx index 2fd5cdea6..e6ecbe216 100644 --- a/packages/stateless/components/layout/Breadcrumbs.tsx +++ b/packages/stateless/components/layout/Breadcrumbs.tsx @@ -17,11 +17,12 @@ export const Breadcrumbs = ({ override = false, homeTab, current, + daoInfo: _daoInfo, className, }: BreadcrumbsProps) => { const { t } = useTranslation() // Allow using Breadcrumbs outside of DaoPageWrapper. - const daoInfo = useDaoInfoContextIfAvailable() + const daoInfo = useDaoInfoContextIfAvailable() || _daoInfo const { mode } = useAppContext() const { getDaoPath } = useDaoNavHelpers() diff --git a/packages/types/components/Breadcrumbs.ts b/packages/types/components/Breadcrumbs.ts index 296a8e263..94bac8047 100644 --- a/packages/types/components/Breadcrumbs.ts +++ b/packages/types/components/Breadcrumbs.ts @@ -1,6 +1,6 @@ import { ReactNode } from 'react' -import { DaoTabId } from '../dao' +import { DaoInfo, DaoTabId } from '../dao' export type BreadcrumbCrumb = { href: string @@ -31,6 +31,11 @@ export type BreadcrumbsProps = { * The current crumb. */ current: ReactNode + /** + * DAO info, if this is being rendered outside of the context provider (like + * in the PageHeader), but still needs access to the DAO info. + */ + daoInfo?: DaoInfo | null /** * Optional container class name. */