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
86dae1c2
Commit
86dae1c2
authored
Aug 30, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes
parent
89b23b3f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
21 deletions
+21
-21
useFetchProfileInfo.tsx
lib/hooks/useFetchProfileInfo.tsx
+11
-0
ProfileMenuDesktop.tsx
ui/blocks/profileMenu/ProfileMenuDesktop.tsx
+2
-10
ProfileMenuMobile.tsx
ui/blocks/profileMenu/ProfileMenuMobile.tsx
+2
-10
MyProfile.tsx
ui/pages/MyProfile.tsx
+6
-1
No files found.
lib/hooks/useFetchProfileInfo.tsx
0 → 100644
View file @
86dae1c2
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
type
{
UserInfo
}
from
'
types/api/account
'
;
import
fetch
from
'
lib/client/fetch
'
;
export
default
function
useFetchProfileInfo
()
{
return
useQuery
<
unknown
,
unknown
,
UserInfo
>
([
'
profile
'
],
async
()
=>
{
return
fetch
(
'
/api/account/profile
'
);
},
{
refetchOnMount
:
false
});
}
ui/blocks/profileMenu/ProfileMenuDesktop.tsx
View file @
86dae1c2
import
{
Popover
,
PopoverContent
,
PopoverBody
,
PopoverTrigger
,
Button
}
from
'
@chakra-ui/react
'
;
import
{
Popover
,
PopoverContent
,
PopoverBody
,
PopoverTrigger
,
Button
}
from
'
@chakra-ui/react
'
;
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
UserInfo
}
from
'
types/api/account
'
;
import
useFetchProfileInfo
from
'
lib/hooks/useFetchProfileInfo
'
;
import
ProfileMenuContent
from
'
ui/blocks/profileMenu/ProfileMenuContent
'
;
import
ProfileMenuContent
from
'
ui/blocks/profileMenu/ProfileMenuContent
'
;
import
UserAvatar
from
'
ui/shared/UserAvatar
'
;
import
UserAvatar
from
'
ui/shared/UserAvatar
'
;
const
ProfileMenuDesktop
=
()
=>
{
const
ProfileMenuDesktop
=
()
=>
{
const
{
data
}
=
useQuery
<
unknown
,
unknown
,
UserInfo
>
([
'
profile
'
],
async
()
=>
{
const
{
data
}
=
useFetchProfileInfo
();
const
response
=
await
fetch
(
'
/api/account/profile
'
);
if
(
!
response
.
ok
)
{
throw
new
Error
(
'
Network response was not ok
'
);
}
return
response
.
json
();
});
return
(
return
(
<
Popover
openDelay=
{
300
}
placement=
"bottom-end"
gutter=
{
10
}
isLazy
>
<
Popover
openDelay=
{
300
}
placement=
"bottom-end"
gutter=
{
10
}
isLazy
>
...
...
ui/blocks/profileMenu/ProfileMenuMobile.tsx
View file @
86dae1c2
import
{
Flex
,
Box
,
Drawer
,
DrawerOverlay
,
DrawerContent
,
DrawerBody
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
import
{
Flex
,
Box
,
Drawer
,
DrawerOverlay
,
DrawerContent
,
DrawerBody
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
UserInfo
}
from
'
types/api/account
'
;
import
useFetchProfileInfo
from
'
lib/hooks/useFetchProfileInfo
'
;
import
ColorModeToggler
from
'
ui/blocks/header/ColorModeToggler
'
;
import
ColorModeToggler
from
'
ui/blocks/header/ColorModeToggler
'
;
import
ProfileMenuContent
from
'
ui/blocks/profileMenu/ProfileMenuContent
'
;
import
ProfileMenuContent
from
'
ui/blocks/profileMenu/ProfileMenuContent
'
;
import
UserAvatar
from
'
ui/shared/UserAvatar
'
;
import
UserAvatar
from
'
ui/shared/UserAvatar
'
;
...
@@ -11,13 +9,7 @@ import UserAvatar from 'ui/shared/UserAvatar';
...
@@ -11,13 +9,7 @@ import UserAvatar from 'ui/shared/UserAvatar';
const
ProfileMenuMobile
=
()
=>
{
const
ProfileMenuMobile
=
()
=>
{
const
{
isOpen
,
onOpen
,
onClose
}
=
useDisclosure
();
const
{
isOpen
,
onOpen
,
onClose
}
=
useDisclosure
();
const
{
data
}
=
useQuery
<
unknown
,
unknown
,
UserInfo
>
([
'
profile
'
],
async
()
=>
{
const
{
data
}
=
useFetchProfileInfo
();
const
response
=
await
fetch
(
'
/api/account/profile
'
);
if
(
!
response
.
ok
)
{
throw
new
Error
(
'
Network response was not ok
'
);
}
return
response
.
json
();
});
return
(
return
(
<>
<>
...
...
ui/pages/MyProfile.tsx
View file @
86dae1c2
...
@@ -6,6 +6,7 @@ import type { UserInfo } from 'types/api/account';
...
@@ -6,6 +6,7 @@ import type { UserInfo } from 'types/api/account';
import
AccountPageHeader
from
'
ui/shared/AccountPageHeader
'
;
import
AccountPageHeader
from
'
ui/shared/AccountPageHeader
'
;
import
ContentLoader
from
'
ui/shared/ContentLoader
'
;
import
ContentLoader
from
'
ui/shared/ContentLoader
'
;
import
DataFetchAlert
from
'
ui/shared/DataFetchAlert
'
;
import
Page
from
'
ui/shared/Page/Page
'
;
import
Page
from
'
ui/shared/Page/Page
'
;
import
UserAvatar
from
'
ui/shared/UserAvatar
'
;
import
UserAvatar
from
'
ui/shared/UserAvatar
'
;
...
@@ -19,10 +20,14 @@ const MyProfile = () => {
...
@@ -19,10 +20,14 @@ const MyProfile = () => {
});
});
const
content
=
(()
=>
{
const
content
=
(()
=>
{
if
(
isLoading
||
isError
)
{
if
(
isLoading
)
{
return
<
ContentLoader
/>;
return
<
ContentLoader
/>;
}
}
if
(
isError
)
{
return
<
DataFetchAlert
/>;
}
return
(
return
(
<
VStack
maxW=
"412px"
mt=
{
12
}
gap=
{
5
}
alignItems=
"stretch"
>
<
VStack
maxW=
"412px"
mt=
{
12
}
gap=
{
5
}
alignItems=
"stretch"
>
<
UserAvatar
size=
{
64
}
data=
{
data
}
/>
<
UserAvatar
size=
{
64
}
data=
{
data
}
/>
...
...
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