const CoADaoId = props.dev ? "coa.gwg-testing.near" : "congress-coa-v1.ndc-gwg.near"; const VotingBodyDaoId = props.dev ? "voting-body-v1.gwg-testing.near" : "voting-body-v1.ndc-gwg.near"; const TCDaoId = props.dev ? "tc.gwg-testing.near" : "congress-tc-v1.ndc-gwg.near"; const HoMDaoId = props.dev ? "hom.gwg-testing.near" : "congress-hom-v1.ndc-gwg.near"; const veganfriendsDaoId = "vegan-friends.sputnik-dao.near"; let { page, tab, daoId, house } = props; if (!page) { page = "dao-feed"; } const currentLink = "#/veganfriends.near/widget/VFhome"; State.init({ activePage: page, activeTab: tab, activeDaoId: daoId, }); if ( page !== state.activePage || tab !== state.activeTab || daoId !== state.activeDaoId ) { State.update({ activePage: page, activeTab: tab, activeDaoId: daoId, }); } page = state.activePage; const router = { params: { page, tab, daoId, house }, navigate: (newParams) => { router.params = { ...newParams, }; State.update({ activePage: router.params.page, activeTab: router.params.tab, activeDaoId: router.params.daoId, }); }, }; const pages = [ [ { title: "Home", icon: <i className="bi bi-house-door"></i>, href: currentLink + `?page=dao&daoId=vegan-friends.sputnik-dao.near`, }, { title: "My proposals", active: page === "my-proposals", href: currentLink + "?page=my-proposals", onClick: () => router.navigate({ page: "my-proposals" }), widgetName: "MyProposals.index", defaultProps: {}, }, ], [ { title: "DAOs", icon: <i class="bi bi-grid"></i>, active: page === "daos", href: currentLink + "?page=daos", onClick: () => router.navigate({ page: "daos" }), widgetName: "DAOs.index", defaultProps: {}, }, { title: "My DAOs", active: page === "my-daos", href: currentLink + "?page=my-daos", widgetName: "DAOs.index", onClick: () => router.navigate({ page: "my-daos" }), defaultProps: { filter: "myDAOs", }, }, ], [ { title: "DAO Feed", icon: <i class="bi bi-chat-dots"></i>, active: page === "dao-feed", href: currentLink + "?page=dao-feed", onClick: () => router.navigate({ page: "dao-feed" }), widgetName: "DAO.Feed", defaultProps: {}, }, ], { title: "Create DAO", active: page === "create-dao", href: currentLink + "?page=create-dao", onClick: () => router.navigate({ page: "create-dao" }), widgetName: "CreateDAO.index", hidden: true, }, { title: "DAO", active: page === "dao", href: currentLink + "?page=dao", onClick: (daoId, tab) => router.navigate({ page: "dao", daoId, tab }), widgetName: "DAO.index", hidden: true, }, { title: "Voting History", active: page === "votinghistory", href: currentLink + "?page=votinghistory", onClick: (daoId, tab) => router.navigate({ page: "votinghistory" }), widgetName: "VotingHistory.index", hidden: true, }, ]; let activePage = null; pages.find((page) => { if (Array.isArray(page)) { return page.find((subPage) => { if (subPage.active) { activePage = subPage; return true; } return false; }); } if (page.active) { activePage = page; return true; } return false; }); const pageContent = activePage ? ( <Widget src={"veganfriends.near/widget/" + activePage.widgetName} props={{ router, ...activePage.defaultProps, ...props, }} /> ) : ( "404" ); const Root = styled.div` font-family: "Open Sans", "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; line-height: 1.5; color: #000; a { color: #000; text-decoration: none; } a:hover { color: #4498e0; } .ndc-card { border-radius: 16px; box-shadow: rgba(0, 0, 0, 0.1) 0 1px 3px, rgba(0, 0, 0, 0.05) 0 1px 20px; background-color: #fff; } `; return ( <Root className="row"> <Widget src={`nearui.near/widget/Typography.OpenSansFont`} /> <Widget src="veganfriends.near/widget/Common.Layout.Header" props={{ items: pages, }} /> {activePage.widgetName === "Congress.index" ? ( <div className="col">{pageContent}</div> ) : ( <div className="col ms-sm-4 ps-lg-5 py-3 py-md-5" style={{ width: "65%" }} > {pageContent} </div> )} </Root> );