Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
63a7e7bd
Commit
63a7e7bd
authored
Jun 19, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
show profile menu if email is not confirmed
parent
46e795fe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
52 deletions
+56
-52
ProfileMenuContent.tsx
ui/snippets/profileMenu/ProfileMenuContent.tsx
+25
-19
ProfileMenuDesktop.tsx
ui/snippets/profileMenu/ProfileMenuDesktop.tsx
+15
-16
ProfileMenuMobile.tsx
ui/snippets/profileMenu/ProfileMenuMobile.tsx
+16
-17
No files found.
ui/snippets/profileMenu/ProfileMenuContent.tsx
View file @
63a7e7bd
...
...
@@ -8,31 +8,37 @@ import useNavItems from 'lib/hooks/useNavItems';
import
getDefaultTransitionProps
from
'
theme/utils/getDefaultTransitionProps
'
;
import
NavLink
from
'
ui/snippets/navigation/NavLink
'
;
type
Props
=
UserInfo
;
type
Props
=
{
data
?:
UserInfo
;
};
const
ProfileMenuContent
=
({
name
,
nickname
,
email
}:
Props
)
=>
{
const
ProfileMenuContent
=
({
data
}:
Props
)
=>
{
const
{
accountNavItems
,
profileItem
}
=
useNavItems
();
const
primaryTextColor
=
useColorModeValue
(
'
blackAlpha.800
'
,
'
whiteAlpha.800
'
);
return
(
<
Box
>
<
Text
fontSize=
"sm"
fontWeight=
{
500
}
color=
{
primaryTextColor
}
{
...
getDefaultTransitionProps
()
}
>
Signed in as
{
name
||
nickname
}
</
Text
>
<
Text
fontSize=
"sm"
mb=
{
1
}
fontWeight=
{
500
}
color=
"gray.500"
{
...
getDefaultTransitionProps
()
}
>
{
email
}
</
Text
>
{
(
data
?.
name
||
data
?.
nickname
)
&&
(
<
Text
fontSize=
"sm"
fontWeight=
{
500
}
color=
{
primaryTextColor
}
{
...
getDefaultTransitionProps
()
}
>
Signed in as
{
data
.
name
||
data
.
nickname
}
</
Text
>
)
}
{
data
?.
email
&&
(
<
Text
fontSize=
"sm"
mb=
{
1
}
fontWeight=
{
500
}
color=
"gray.500"
{
...
getDefaultTransitionProps
()
}
>
{
data
.
email
}
</
Text
>
)
}
<
NavLink
item=
{
profileItem
}
isActive=
{
undefined
}
px=
"0px"
isCollapsed=
{
false
}
/>
<
Box
as=
"nav"
mt=
{
2
}
pt=
{
2
}
borderTopColor=
"divider"
borderTopWidth=
"1px"
{
...
getDefaultTransitionProps
()
}
>
<
VStack
as=
"ul"
spacing=
"0"
alignItems=
"flex-start"
overflow=
"hidden"
>
...
...
ui/snippets/profileMenu/ProfileMenuDesktop.tsx
View file @
63a7e7bd
import
type
{
ButtonProps
}
from
'
@chakra-ui/react
'
;
import
{
Popover
,
PopoverContent
,
PopoverBody
,
PopoverTrigger
,
Button
}
from
'
@chakra-ui/react
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
React
from
'
react
'
;
import
useFetchProfileInfo
from
'
lib/hooks/useFetchProfileInfo
'
;
...
...
@@ -9,25 +8,25 @@ import UserAvatar from 'ui/shared/UserAvatar';
import
ProfileMenuContent
from
'
ui/snippets/profileMenu/ProfileMenuContent
'
;
const
ProfileMenuDesktop
=
()
=>
{
const
{
data
,
error
}
=
useFetchProfileInfo
();
const
{
data
,
error
,
isLoading
}
=
useFetchProfileInfo
();
const
loginUrl
=
useLoginUrl
();
const
[
hasMenu
,
setHasMenu
]
=
React
.
useState
(
false
);
const
buttonProps
:
Partial
<
ButtonProps
>
=
(()
=>
{
if
(
error
?.
status
===
403
)
{
return
{
as
:
'
a
'
,
href
:
route
({
pathname
:
'
/auth/profile
'
}),
};
React
.
useEffect
(()
=>
{
if
(
!
isLoading
)
{
setHasMenu
(
Boolean
(
data
)
||
error
?.
status
===
403
);
}
},
[
data
,
error
?.
status
,
isLoading
]);
if
(
!
data
)
{
return
{
as
:
'
a
'
,
href
:
loginUrl
,
};
const
buttonProps
:
Partial
<
ButtonProps
>
=
(()
=>
{
if
(
hasMenu
)
{
return
{};
}
return
{};
return
{
as
:
'
a
'
,
href
:
loginUrl
,
};
})();
return
(
...
...
@@ -43,10 +42,10 @@ const ProfileMenuDesktop = () => {
<
UserAvatar
size=
{
50
}
/>
</
Button
>
</
PopoverTrigger
>
{
data
&&
(
{
hasMenu
&&
(
<
PopoverContent
w=
"212px"
>
<
PopoverBody
padding=
"24px 16px 16px 16px"
>
<
ProfileMenuContent
{
...
data
}
/>
<
ProfileMenuContent
data=
{
data
}
/>
</
PopoverBody
>
</
PopoverContent
>
)
}
...
...
ui/snippets/profileMenu/ProfileMenuMobile.tsx
View file @
63a7e7bd
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
useFetchProfileInfo
from
'
lib/hooks/useFetchProfileInfo
'
;
...
...
@@ -11,30 +10,30 @@ import ProfileMenuContent from 'ui/snippets/profileMenu/ProfileMenuContent';
const
ProfileMenuMobile
=
()
=>
{
const
{
isOpen
,
onOpen
,
onClose
}
=
useDisclosure
();
const
{
data
,
error
}
=
useFetchProfileInfo
();
const
{
data
,
error
,
isLoading
}
=
useFetchProfileInfo
();
const
loginUrl
=
useLoginUrl
();
const
[
hasMenu
,
setHasMenu
]
=
React
.
useState
(
false
);
const
buttonProps
:
Partial
<
ButtonProps
>
=
(()
=>
{
if
(
error
?.
status
===
403
)
{
return
{
as
:
'
a
'
,
href
:
route
({
pathname
:
'
/auth/profile
'
}),
};
React
.
useEffect
(()
=>
{
if
(
!
isLoading
)
{
setHasMenu
(
Boolean
(
data
)
||
error
?.
status
===
403
);
}
},
[
data
,
error
?.
status
,
isLoading
]);
if
(
!
data
)
{
return
{
as
:
'
a
'
,
href
:
loginUrl
,
};
const
buttonProps
:
Partial
<
ButtonProps
>
=
(()
=>
{
if
(
hasMenu
)
{
return
{};
}
return
{};
return
{
as
:
'
a
'
,
href
:
loginUrl
,
};
})();
return
(
<>
<
Box
padding=
{
2
}
onClick=
{
data
?
onOpen
:
undefined
}
>
<
Box
padding=
{
2
}
onClick=
{
hasMenu
?
onOpen
:
undefined
}
>
<
Button
variant=
"unstyled"
height=
"auto"
...
...
@@ -43,7 +42,7 @@ const ProfileMenuMobile = () => {
<
UserAvatar
size=
{
24
}
/>
</
Button
>
</
Box
>
{
data
&&
(
{
hasMenu
&&
(
<
Drawer
isOpen=
{
isOpen
}
placement=
"right"
...
...
@@ -53,7 +52,7 @@ const ProfileMenuMobile = () => {
<
DrawerOverlay
/>
<
DrawerContent
maxWidth=
"260px"
>
<
DrawerBody
p=
{
6
}
>
<
ProfileMenuContent
{
...
data
}
/>
<
ProfileMenuContent
data=
{
data
}
/>
</
DrawerBody
>
</
DrawerContent
>
</
Drawer
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment