Commit 4b18a656 authored by tom's avatar tom

handle case when wc is disabled

parent 1878c18b
......@@ -28,6 +28,7 @@ const logoutUrl = (() => {
})();
const title = 'My account';
// TODO @tom2drum add condition for recaptcha
const config: Feature<{ authUrl: string; logoutUrl: string }> = (() => {
if (
......
import { Flex } from '@chakra-ui/react';
import React from 'react';
import config from 'configs/app';
import useFetchProfileInfo from 'lib/hooks/useFetchProfileInfo';
import useRedirectForInvalidAuthToken from 'lib/hooks/useRedirectForInvalidAuthToken';
import MyProfileEmail from 'ui/myProfile/MyProfileEmail';
......@@ -25,7 +26,7 @@ const MyProfile = () => {
return (
<Flex maxW="480px" mt={ 8 } flexDir="column" rowGap={ 12 }>
<MyProfileEmail profileQuery={ profileQuery }/>
<MyProfileWallet profileQuery={ profileQuery }/>
{ config.features.blockchainInteraction.isEnabled && <MyProfileWallet profileQuery={ profileQuery }/> }
</Flex>
);
})();
......
......@@ -2,6 +2,7 @@ import { useWeb3Modal } from '@web3modal/wagmi/react';
import React from 'react';
import { useSignMessage } from 'wagmi';
import config from 'configs/app';
import useApiFetch from 'lib/api/useApiFetch';
import getErrorMessage from 'lib/errors/getErrorMessage';
import useToast from 'lib/hooks/useToast';
......@@ -12,7 +13,7 @@ interface Props {
onError?: () => void;
}
export default function useSignInWithWallet({ onSuccess, onError }: Props) {
function useSignInWithWallet({ onSuccess, onError }: Props) {
const [ isPending, setIsPending ] = React.useState(false);
const isConnectingWalletRef = React.useRef(false);
......@@ -65,3 +66,9 @@ export default function useSignInWithWallet({ onSuccess, onError }: Props) {
return React.useMemo(() => ({ start, isPending }), [ start, isPending ]);
}
function useSignInWithWalletFallback() {
return React.useMemo(() => ({ start: () => {}, isPending: false }), [ ]);
}
export default config.features.blockchainInteraction.isEnabled ? useSignInWithWallet : useSignInWithWalletFallback;
......@@ -2,6 +2,7 @@ import { PopoverBody, PopoverContent, PopoverTrigger, useDisclosure, type Button
import { useRouter } from 'next/router';
import React from 'react';
import config from 'configs/app';
import useFetchProfileInfo from 'lib/hooks/useFetchProfileInfo';
import Popover from 'ui/shared/chakra/Popover';
import AuthModal from 'ui/snippets/auth/AuthModal';
......@@ -58,7 +59,12 @@ const ProfileDesktop = ({ buttonSize, buttonVariant = 'header' }: Props) => {
</PopoverContent>
) }
</Popover>
{ authModal.isOpen && <AuthModal onClose={ authModal.onClose } initialScreen={{ type: 'select_method' }}/> }
{ authModal.isOpen && (
<AuthModal
onClose={ authModal.onClose }
initialScreen={{ type: config.features.blockchainInteraction.isEnabled ? 'select_method' : 'email' }}
/>
) }
</>
);
};
......
......@@ -66,7 +66,7 @@ const ProfileMenuContent = ({ data, onClose }: Props) => {
{ data?.email && <Text variant="secondary" fontSize="sm">{ getUserHandle(data.email) }</Text> }
</Flex>
<ProfileMenuWallet onClose={ onClose }/>
{ config.features.blockchainInteraction.isEnabled ? <ProfileMenuWallet onClose={ onClose }/> : <Divider/> }
<VStack as="ul" spacing="0" alignItems="flex-start" overflow="hidden">
{ navLinks.map((item) => (
......
import { Button, Divider, Flex, IconButton } from '@chakra-ui/react';
import React from 'react';
import config from 'configs/app';
import delay from 'lib/delay';
import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import IconSvg from 'ui/shared/IconSvg';
......@@ -30,10 +29,6 @@ const ProfileMenuWallet = ({ onClose }: Props) => {
onClose?.();
}, [ wallet, onClose ]);
if (!config.features.blockchainInteraction.isEnabled) {
return <Divider/>;
}
if (wallet.isWalletConnected && web3AccountWithDomain.address) {
return (
<>
......
......@@ -2,6 +2,7 @@ import { Drawer, DrawerBody, DrawerContent, DrawerOverlay, useDisclosure } from
import { useRouter } from 'next/router';
import React from 'react';
import config from 'configs/app';
import useFetchProfileInfo from 'lib/hooks/useFetchProfileInfo';
import AuthModal from 'ui/snippets/auth/AuthModal';
import useSignInWithWallet from 'ui/snippets/auth/useSignInWithWallet';
......@@ -54,7 +55,12 @@ const ProfileMobile = () => {
</DrawerContent>
</Drawer>
) }
{ authModal.isOpen && <AuthModal onClose={ authModal.onClose } initialScreen={{ type: 'select_method' }}/> }
{ authModal.isOpen && (
<AuthModal
onClose={ authModal.onClose }
initialScreen={{ type: config.features.blockchainInteraction.isEnabled ? 'select_method' : 'email' }}
/>
) }
</>
);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment