Skip to content

Commit

Permalink
Merge pull request #1324 from decent-dao/develop
Browse files Browse the repository at this point in the history
Merge develop into main for production deployment
  • Loading branch information
mudrila authored Jan 22, 2024
2 parents 25ea1ef + 93453fa commit a6c07cf
Show file tree
Hide file tree
Showing 41 changed files with 811 additions and 276 deletions.
62 changes: 49 additions & 13 deletions app/daos/[daoAddress]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
'use client';

import { Button, Center, Text, VStack } from '@chakra-ui/react';
import { ReactNode } from 'react';
import { Button, Center, Text, VStack, ChakraProvider, extendTheme } from '@chakra-ui/react';
import { theme } from '@decent-org/fractal-ui';
import Script from 'next/script';
import { ReactNode, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useNetwork } from 'wagmi';
import ClientOnly from '../../../src/components/ui/utils/ClientOnly';
import { APP_NAME } from '../../../src/constants/common';
import useDAOController from '../../../src/hooks/DAO/useDAOController';
import useDAOMetadata from '../../../src/hooks/DAO/useDAOMetadata';
import { useFractal } from '../../../src/providers/App/AppProvider';
import {
disconnectedChain,
Expand All @@ -30,13 +33,7 @@ function InvalidSafe() {
</Text>
<Text>{t('invalidSafe1', { chain: chain ? chain.name : disconnectedChain.name })}</Text>
<Text paddingBottom="1rem">{t('invalidSafe2')}</Text>
<Button
onClick={() => {
window.location.reload();
}}
>
{t('refresh')}
</Button>
<Button onClick={() => window.location.reload()}>{t('refresh')}</Button>
</VStack>
</Center>
);
Expand Down Expand Up @@ -74,17 +71,41 @@ export default function DaoPageLayout({
params: { daoAddress?: string };
}) {
const { node } = useFractal();
const loading = useDAOController({ daoAddress });
const { nodeLoading, reloadingDAO, errorLoading } = useDAOController({ daoAddress });
const daoMetadata = useDAOMetadata();
const { chain } = useNetwork();
const activeTheme = useMemo(() => {
if (daoMetadata && daoMetadata.bodyBackground) {
return extendTheme({
...theme,
styles: {
...theme.styles,
global: {
...theme.styles.global,
html: {
...theme.styles.global.html,
background: daoMetadata.bodyBackground,
},
body: {
...theme.styles.global.body,
background: 'none',
},
},
},
});
}
return theme;
}, [daoMetadata]);

const validSafe = node.safe;
let display;
const childrenDisplay = <ChakraProvider theme={activeTheme}>{children}</ChakraProvider>;

if (process.env.NEXT_PUBLIC_TESTING_ENVIRONMENT) {
display = children;
display = childrenDisplay;
} else if (!chain) {
// if we're disconnected
if (loading || validSafe) {
if (nodeLoading || reloadingDAO || validSafe || !errorLoading) {
display = children;
} else {
display = <InvalidSafe />;
Expand All @@ -94,7 +115,7 @@ export default function DaoPageLayout({
const invalidChain = !supportedChains.map(c => c.chainId).includes(chain.id);
if (invalidChain) {
display = <InvalidChain />;
} else if (loading || validSafe) {
} else if (nodeLoading || reloadingDAO || validSafe || !errorLoading) {
display = children;
} else {
display = <InvalidSafe />;
Expand All @@ -104,6 +125,21 @@ export default function DaoPageLayout({
return (
<ClientOnly>
<title>{node?.daoName ? `${node.daoName} | ${APP_NAME}` : APP_NAME}</title>
{node && node.daoAddress === '0x167bE4073f52aD2Aa0D6d6FeddF0F1f79a82B98e' && (
<Script
id="ethlizards-hotjar-tracking"
strategy="afterInteractive"
>
{`(function(h,o,t,j,a,r){
h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
h._hjSettings={hjid:3776270,hjsv:6};
a=o.getElementsByTagName('head')[0];
r=o.createElement('script');r.async=1;
r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
a.appendChild(r);
})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');`}
</Script>
)}
{display}
</ClientOnly>
);
Expand Down
17 changes: 12 additions & 5 deletions app/daos/[daoAddress]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@
import { Activities } from '../../../src/components/pages/DaoDashboard/Activities';
import { ERCO20Claim } from '../../../src/components/pages/DaoDashboard/ERC20Claim';
import { Info } from '../../../src/components/pages/DaoDashboard/Info';
import InfoHeader from '../../../src/components/pages/DaoDashboard/Info/InfoHeader';
import ClientOnly from '../../../src/components/ui/utils/ClientOnly';
import useDAOMetadata from '../../../src/hooks/DAO/useDAOMetadata';

export default function DaoDashboardPage() {
const daoMetadata = useDAOMetadata();

return (
<ClientOnly mt={12}>
<Info />
<ERCO20Claim />
<Activities />
</ClientOnly>
<>
<InfoHeader />
<ClientOnly mt={!!daoMetadata ? 40 : 12}>
<Info />
<ERCO20Claim />
<Activities />
</ClientOnly>
</>
);
}
44 changes: 43 additions & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { useNetwork } from 'wagmi';
import { goerli, mainnet } from 'wagmi/chains';
import { goerli, mainnet, sepolia } from 'wagmi/chains';
import { AppFooter } from '../src/components/pages/AppHome/AppFooter';
import { CTABox } from '../src/components/pages/AppHome/CTABox';
import FeaturedDAOCard from '../src/components/pages/AppHome/FeaturedDAOCard';
Expand All @@ -14,6 +14,7 @@ import ExternalLink from '../src/components/ui/links/ExternalLink';
import ClientOnly from '../src/components/ui/utils/ClientOnly';
import { BASE_ROUTES } from '../src/constants/routes';
import { URL_DOCS } from '../src/constants/url';
import ethLizardsLogo from '../src/metadata/lizzardsDAO/assets/logo.png';
import { useFractal } from '../src/providers/App/AppProvider';
import { disconnectedChain } from '../src/providers/NetworkConfig/NetworkConfigProvider';

Expand Down Expand Up @@ -59,6 +60,12 @@ const FEATURED_DAOS = new Map<number, Feature[]>([
descKey: 'awakeDesc',
address: '0x36C19472D4CA942710cA9aF01a03cED4dBc6eC0a',
},
{
iconSrc: ethLizardsLogo.src,
titleKey: 'ethlizardsTitle',
descKey: 'ethlizardsDesc',
address: '0x167bE4073f52aD2Aa0D6d6FeddF0F1f79a82B98e',
},
],
],
[
Expand All @@ -76,6 +83,35 @@ const FEATURED_DAOS = new Map<number, Feature[]>([
descKey: 'awakeDesc',
address: '0xdD6CeFA62239272f1eDf755ba6471eacb7DF2Fa5',
},
{
iconSrc: ethLizardsLogo.src,
titleKey: 'ethlizardsTitle',
descKey: 'ethlizardsDesc',
address: '0x167bE4073f52aD2Aa0D6d6FeddF0F1f79a82B98e', // TODO: Change to mainnet address once it will be there
},
],
],
[
sepolia.id,
[
{
iconSrc: '/images/icon-decent.svg',
titleKey: 'decentTitle',
descKey: 'decentDesc',
address: '0xD26c85D435F02DaB8B220cd4D2d398f6f646e235', // TODO: Change to Sepolia Address once it will be there
},
{
iconSrc: '/images/icon-awakevc.svg',
titleKey: 'awakeTitle',
descKey: 'awakeDesc',
address: '0xdD6CeFA62239272f1eDf755ba6471eacb7DF2Fa5', // TODO: Change to Sepolia Address once it will be there
},
{
iconSrc: ethLizardsLogo.src,
titleKey: 'ethlizardsTitle',
descKey: 'ethlizardsDesc',
address: '0x167bE4073f52aD2Aa0D6d6FeddF0F1f79a82B98e', // TODO: Change to Sepolia address once it will be there
},
],
],
]);
Expand Down Expand Up @@ -199,6 +235,12 @@ export default function HomePage() {
paddingBottom="1.5rem"
>
{features.map((feature, index) => {
if (
typeof location !== 'undefined' &&
location.pathname === 'app.fractalframework.xyz'
) {
return null;
}
return (
<FeaturedDAOCard
width={{ sm: '100%', lg: '50%' }}
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"@apollo/client": "^3.7.10",
"@chakra-ui/next-js": "^2.0.1",
"@chakra-ui/react": "^2.5.2",
"@decent-org/fractal-ui": "^0.1.21",
"@decent-org/fractal-ui": "^0.1.22",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@fontsource/ibm-plex-mono": "^4.5.12",
"@fontsource/ibm-plex-sans": "^4.5.13",
"@fractal-framework/fractal-contracts": "^0.3.6",
"@fractal-framework/fractal-contracts": "^0.4.0",
"@graphprotocol/client-apollo": "^1.0.16",
"@lido-sdk/contracts": "^3.0.2",
"@rainbow-me/rainbowkit": "^0.8.1",
Expand Down
52 changes: 23 additions & 29 deletions src/components/Proposals/ProposalActions/ProposalAction.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { Button, Flex, Text } from '@chakra-ui/react';
import { useRouter } from 'next/navigation';
import Link from 'next/link';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { BACKGROUND_SEMI_TRANSPARENT } from '../../../constants/common';
import { DAO_ROUTES } from '../../../constants/routes';
import useSnapshotProposal from '../../../hooks/DAO/loaders/snapshot/useSnapshotProposal';
import { useFractal } from '../../../providers/App/AppProvider';
import {
ExtendedSnapshotProposal,
FractalProposal,
FractalProposalState,
SnapshotProposal,
} from '../../../types';
import { ExtendedSnapshotProposal, FractalProposal, FractalProposalState } from '../../../types';
import ContentBox from '../../ui/containers/ContentBox';
import { ProposalCountdown } from '../../ui/proposal/ProposalCountdown';
import { useVoteContext } from '../ProposalVotes/context/VoteContext';
Expand Down Expand Up @@ -60,7 +55,6 @@ export function ProposalAction({
node: { daoAddress },
readOnly: { user, dao },
} = useFractal();
const { push } = useRouter();
const { t } = useTranslation();
const { isSnapshotProposal } = useSnapshotProposal(proposal);
const { canVote } = useVoteContext();
Expand All @@ -71,23 +65,13 @@ export function ProposalAction({
);

const showActionButton =
(isSnapshotProposal && canVote) ||
(isSnapshotProposal && canVote && isActiveProposal) ||
(user.votingWeight.gt(0) &&
(isActiveProposal ||
proposal.state === FractalProposalState.EXECUTABLE ||
proposal.state === FractalProposalState.TIMELOCKABLE ||
proposal.state === FractalProposalState.TIMELOCKED));

const handleClick = () => {
if (isSnapshotProposal) {
push(
DAO_ROUTES.proposal.relative(daoAddress, (proposal as SnapshotProposal).snapshotProposalId)
);
} else {
push(DAO_ROUTES.proposal.relative(daoAddress, proposal.proposalId));
}
};

const labelKey = useMemo(() => {
switch (proposal.state) {
case FractalProposalState.ACTIVE:
Expand Down Expand Up @@ -119,12 +103,17 @@ export function ProposalAction({
if (!showActionButton) {
if (!expandedView) {
return (
<Button
variant="secondary"
onClick={handleClick}
<Link
href={DAO_ROUTES.proposal.relative(daoAddress, proposal.proposalId)}
passHref
>
{t('details')}
</Button>
<Button
as="a"
variant="secondary"
>
{t('details')}
</Button>
</Link>
);
}
// This means that Proposal in state where there's no action to perform
Expand Down Expand Up @@ -155,11 +144,16 @@ export function ProposalAction({
}

return (
<Button
onClick={handleClick}
variant={showActionButton && canVote ? 'primary' : 'secondary'}
<Link
href={DAO_ROUTES.proposal.relative(daoAddress, proposal.proposalId)}
passHref
>
{label}
</Button>
<Button
as="a"
variant={showActionButton && canVote ? 'primary' : 'secondary'}
>
{label}
</Button>
</Link>
);
}
Loading

0 comments on commit a6c07cf

Please sign in to comment.