Commit c7b55618 authored by tom's avatar tom

fix email confirmation for profile menu and verified addresses

parent 6015bb72
...@@ -16,6 +16,7 @@ declare module "nextjs-routes" { ...@@ -16,6 +16,7 @@ declare module "nextjs-routes" {
| DynamicRoute<"/address/[hash]/contract_verification", { "hash": string }> | DynamicRoute<"/address/[hash]/contract_verification", { "hash": string }>
| DynamicRoute<"/address/[hash]", { "hash": string }> | DynamicRoute<"/address/[hash]", { "hash": string }>
| StaticRoute<"/api/csrf"> | StaticRoute<"/api/csrf">
| StaticRoute<"/api/healthz">
| StaticRoute<"/api/media-type"> | StaticRoute<"/api/media-type">
| StaticRoute<"/api/proxy"> | StaticRoute<"/api/proxy">
| StaticRoute<"/api-docs"> | StaticRoute<"/api-docs">
......
...@@ -99,6 +99,10 @@ const VerifiedAddresses = () => { ...@@ -99,6 +99,10 @@ const VerifiedAddresses = () => {
}); });
}, [ queryClient ]); }, [ queryClient ]);
if (addressesQuery.isError && addressesQuery.error.status === 403) {
throw new Error('Unverified email error', { cause: addressesQuery.error });
}
const addButton = ( const addButton = (
<Skeleton mt={ 8 } isLoaded={ !isLoading } display="inline-block"> <Skeleton mt={ 8 } isLoaded={ !isLoading } display="inline-block">
<Button size="lg" onClick={ modalProps.onOpen }> <Button size="lg" onClick={ modalProps.onOpen }>
......
import type { ButtonProps } from '@chakra-ui/react';
import { Popover, PopoverContent, PopoverBody, PopoverTrigger, Button } from '@chakra-ui/react'; import { Popover, PopoverContent, PopoverBody, PopoverTrigger, Button } from '@chakra-ui/react';
import { route } from 'nextjs-routes';
import React from 'react'; import React from 'react';
import useFetchProfileInfo from 'lib/hooks/useFetchProfileInfo'; import useFetchProfileInfo from 'lib/hooks/useFetchProfileInfo';
...@@ -7,9 +9,27 @@ import UserAvatar from 'ui/shared/UserAvatar'; ...@@ -7,9 +9,27 @@ import UserAvatar from 'ui/shared/UserAvatar';
import ProfileMenuContent from 'ui/snippets/profileMenu/ProfileMenuContent'; import ProfileMenuContent from 'ui/snippets/profileMenu/ProfileMenuContent';
const ProfileMenuDesktop = () => { const ProfileMenuDesktop = () => {
const { data } = useFetchProfileInfo(); const { data, error } = useFetchProfileInfo();
const loginUrl = useLoginUrl(); const loginUrl = useLoginUrl();
const buttonProps: Partial<ButtonProps> = (() => {
if (error?.status === 403) {
return {
as: 'a',
href: route({ pathname: '/auth/profile' }),
};
}
if (!data) {
return {
as: 'a',
href: loginUrl,
};
}
return {};
})();
return ( return (
<Popover openDelay={ 300 } placement="bottom-end" gutter={ 10 } isLazy> <Popover openDelay={ 300 } placement="bottom-end" gutter={ 10 } isLazy>
<PopoverTrigger> <PopoverTrigger>
...@@ -18,8 +38,7 @@ const ProfileMenuDesktop = () => { ...@@ -18,8 +38,7 @@ const ProfileMenuDesktop = () => {
display="inline-flex" display="inline-flex"
height="auto" height="auto"
flexShrink={ 0 } flexShrink={ 0 }
as={ data ? undefined : 'a' } { ...buttonProps }
href={ data ? undefined : loginUrl }
> >
<UserAvatar size={ 50 }/> <UserAvatar size={ 50 }/>
</Button> </Button>
......
import { Box, Drawer, DrawerOverlay, DrawerContent, DrawerBody, useDisclosure, Button } from '@chakra-ui/react'; import { Box, Drawer, DrawerOverlay, DrawerContent, DrawerBody, useDisclosure, Button } from '@chakra-ui/react';
import type { ButtonProps } from '@chakra-ui/react';
import { route } from 'nextjs-routes';
import React from 'react'; import React from 'react';
import useFetchProfileInfo from 'lib/hooks/useFetchProfileInfo'; import useFetchProfileInfo from 'lib/hooks/useFetchProfileInfo';
...@@ -9,17 +11,34 @@ import ProfileMenuContent from 'ui/snippets/profileMenu/ProfileMenuContent'; ...@@ -9,17 +11,34 @@ import ProfileMenuContent from 'ui/snippets/profileMenu/ProfileMenuContent';
const ProfileMenuMobile = () => { const ProfileMenuMobile = () => {
const { isOpen, onOpen, onClose } = useDisclosure(); const { isOpen, onOpen, onClose } = useDisclosure();
const { data } = useFetchProfileInfo(); const { data, error } = useFetchProfileInfo();
const loginUrl = useLoginUrl(); const loginUrl = useLoginUrl();
const buttonProps: Partial<ButtonProps> = (() => {
if (error?.status === 403) {
return {
as: 'a',
href: route({ pathname: '/auth/profile' }),
};
}
if (!data) {
return {
as: 'a',
href: loginUrl,
};
}
return {};
})();
return ( return (
<> <>
<Box padding={ 2 } onClick={ data ? onOpen : undefined }> <Box padding={ 2 } onClick={ data ? onOpen : undefined }>
<Button <Button
variant="unstyled" variant="unstyled"
height="auto" height="auto"
as={ data ? undefined : 'a' } { ...buttonProps }
href={ data ? undefined : loginUrl }
> >
<UserAvatar size={ 24 }/> <UserAvatar size={ 24 }/>
</Button> </Button>
......
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