Skip to content

Commit

Permalink
DAOController can be empty-path parent
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgall committed Mar 26, 2024
1 parent 782e288 commit 4f5d0e8
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 45 deletions.
11 changes: 8 additions & 3 deletions src/pages/DAOController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Button, Center, Text, VStack, ChakraProvider, extendTheme } from '@chak
import { theme } from '@decent-org/fractal-ui';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { Outlet } from 'react-router-dom';
import useDAOController from '../hooks/DAO/useDAOController';
import useDAOMetadata from '../hooks/DAO/useDAOMetadata';
import { useFractal } from '../providers/App/AppProvider';
Expand Down Expand Up @@ -31,7 +32,7 @@ function InvalidSafe() {
);
}

export default function DAOController({ children }: { children: React.ReactNode }) {
export default function DAOController() {
const { node } = useFractal();
const { nodeLoading, errorLoading } = useDAOController();
const daoMetadata = useDAOMetadata();
Expand Down Expand Up @@ -62,9 +63,13 @@ export default function DAOController({ children }: { children: React.ReactNode
let display;

if (import.meta.env.VITE_APP_TESTING_ENVIRONMENT) {
display = <ChakraProvider theme={activeTheme}>{children}</ChakraProvider>;
display = (
<ChakraProvider theme={activeTheme}>
<Outlet />
</ChakraProvider>
);
} else if (nodeLoading || validSafe || !errorLoading) {
display = <>{children}</>;
display = <Outlet />;
} else {
display = <InvalidSafe />;
}
Expand Down
88 changes: 46 additions & 42 deletions src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export const router = createBrowserRouter([
// within underlying modals. Otherwise - trying to invoke routing-related hooks would lead to crash.
// Not the best place to have this provider here but also more reasonalbe than putting that into <Layout />
<ModalProvider>
<DAOController>
<Layout />
</DAOController>
<Layout />
</ModalProvider>
),
children: [
Expand All @@ -40,59 +38,65 @@ export const router = createBrowserRouter([
element: <DaoCreatePage />,
},
{
path: 'home',
element: <DaoDashboardPage />,
},
{
path: 'edit/governance',
element: <ModifyGovernancePage />,
},
{
path: 'hierarchy',
element: <HierarchyPage />,
},
{
path: 'new',
element: <SubDaoCreate />,
},
{
path: 'proposal-templates',
path: '/',
element: <DAOController />,
children: [
{
index: true,
element: <ProposalTemplatesPage />,
path: 'home',
element: <DaoDashboardPage />,
},
{
path: 'edit/governance',
element: <ModifyGovernancePage />,
},
{
path: 'hierarchy',
element: <HierarchyPage />,
},
{
path: 'new',
element: <CreateProposalTemplatePage />,
element: <SubDaoCreate />,
},
],
},
{
path: 'proposals',
children: [
{
index: true,
element: <ProposalsPage />,
path: 'proposal-templates',
children: [
{
index: true,
element: <ProposalTemplatesPage />,
},
{
path: 'new',
element: <CreateProposalTemplatePage />,
},
],
},
{
path: ':proposalId',
element: <ProposalDetailsPage />,
path: 'proposals',
children: [
{
index: true,
element: <ProposalsPage />,
},
{
path: ':proposalId',
element: <ProposalDetailsPage />,
},
{
path: 'new',
element: <ProposalCreatePage />,
},
],
},
{
path: 'new',
element: <ProposalCreatePage />,
path: 'settings',
element: <SettingsPage />,
},
{
path: 'treasury',
element: <Treasury />,
},
],
},
{
path: 'settings',
element: <SettingsPage />,
},
{
path: 'treasury',
element: <Treasury />,
},
{
// this exists to keep old links working
// /daos/0x0123/* will redirect to /home?dao=0x0123
Expand Down

0 comments on commit 4f5d0e8

Please sign in to comment.