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
9cc3d536
Commit
9cc3d536
authored
Sep 19, 2024
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add logout
parent
b4072735
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
47 additions
and
8 deletions
+47
-8
cookies.ts
lib/cookies.ts
+5
-1
AuthModalScreenConnectWallet.tsx
ui/snippets/auth/screens/AuthModalScreenConnectWallet.tsx
+1
-1
useLogout.tsx
ui/snippets/auth/useLogout.tsx
+33
-0
useSignInWithWallet.tsx
ui/snippets/auth/useSignInWithWallet.tsx
+0
-0
ProfileButton.tsx
ui/snippets/profile/ProfileButton.tsx
+3
-3
ProfileDesktop.tsx
ui/snippets/profile/ProfileDesktop.tsx
+1
-1
ProfileMenuContent.tsx
ui/snippets/profile/ProfileMenuContent.tsx
+3
-1
ProfileMobile.tsx
ui/snippets/profile/ProfileMobile.tsx
+1
-1
No files found.
lib/cookies.ts
View file @
9cc3d536
...
@@ -28,12 +28,16 @@ export function get(name?: NAMES | undefined | null, serverCookie?: string) {
...
@@ -28,12 +28,16 @@ export function get(name?: NAMES | undefined | null, serverCookie?: string) {
}
}
}
}
export
function
set
(
name
:
string
,
value
:
string
,
attributes
:
Cookies
.
CookieAttributes
=
{})
{
export
function
set
(
name
:
NAMES
,
value
:
string
,
attributes
:
Cookies
.
CookieAttributes
=
{})
{
attributes
.
path
=
'
/
'
;
attributes
.
path
=
'
/
'
;
return
Cookies
.
set
(
name
,
value
,
attributes
);
return
Cookies
.
set
(
name
,
value
,
attributes
);
}
}
export
function
remove
(
name
:
NAMES
,
attributes
:
Cookies
.
CookieAttributes
=
{})
{
return
Cookies
.
remove
(
name
,
attributes
);
}
export
function
getFromCookieString
(
cookieString
:
string
,
name
?:
NAMES
|
undefined
|
null
)
{
export
function
getFromCookieString
(
cookieString
:
string
,
name
?:
NAMES
|
undefined
|
null
)
{
return
cookieString
.
split
(
`
${
name
}
=`
)[
1
]?.
split
(
'
;
'
)[
0
];
return
cookieString
.
split
(
`
${
name
}
=`
)[
1
]?.
split
(
'
;
'
)[
0
];
}
}
ui/snippets/auth/screens/AuthModalScreenConnectWallet.tsx
View file @
9cc3d536
...
@@ -3,7 +3,7 @@ import React from 'react';
...
@@ -3,7 +3,7 @@ import React from 'react';
import
type
{
Screen
}
from
'
../types
'
;
import
type
{
Screen
}
from
'
../types
'
;
import
useSignInWithWallet
from
'
./useSignInWithWallet
'
;
import
useSignInWithWallet
from
'
.
.
/useSignInWithWallet
'
;
interface
Props
{
interface
Props
{
onSuccess
:
(
screen
:
Screen
)
=>
void
;
onSuccess
:
(
screen
:
Screen
)
=>
void
;
...
...
ui/snippets/auth/useLogout.tsx
0 → 100644
View file @
9cc3d536
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
type
{
Route
}
from
'
nextjs-routes
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
const
PROTECTED_ROUTES
:
Array
<
Route
[
'
pathname
'
]
>
=
[
'
/account/api-key
'
,
'
/account/custom-abi
'
,
'
/account/tag-address
'
,
'
/account/verified-addresses
'
,
'
/account/watchlist
'
,
'
/auth/profile
'
,
'
/auth/unverified-email
'
,
];
export
default
function
useLogout
()
{
const
router
=
useRouter
();
return
React
.
useCallback
(
async
()
=>
{
cookies
.
remove
(
cookies
.
NAMES
.
API_TOKEN
);
if
(
PROTECTED_ROUTES
.
includes
(
router
.
pathname
)
||
(
router
.
pathname
===
'
/txs
'
&&
router
.
query
.
tab
===
'
watchlist
'
)
)
{
window
.
location
.
assign
(
'
/
'
);
}
else
{
window
.
location
.
reload
();
}
},
[
router
]);
}
ui/snippets/auth/
screens/
useSignInWithWallet.tsx
→
ui/snippets/auth/useSignInWithWallet.tsx
View file @
9cc3d536
File moved
ui/snippets/profile/ProfileButton.tsx
View file @
9cc3d536
import
type
{
ButtonProps
}
from
'
@chakra-ui/react
'
;
import
type
{
ButtonProps
}
from
'
@chakra-ui/react
'
;
import
{
Button
,
Skeleton
,
Tooltip
,
Text
,
HStack
}
from
'
@chakra-ui/react
'
;
import
{
Button
,
Skeleton
,
Tooltip
,
Box
,
HStack
}
from
'
@chakra-ui/react
'
;
import
type
{
UseQueryResult
}
from
'
@tanstack/react-query
'
;
import
type
{
UseQueryResult
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
...
@@ -55,7 +55,7 @@ const ProfileButton = ({ profileQuery, size, variant, onClick, isPending }: Prop
...
@@ -55,7 +55,7 @@ const ProfileButton = ({ profileQuery, size, variant, onClick, isPending }: Prop
return
(
return
(
<
HStack
gap=
{
2
}
>
<
HStack
gap=
{
2
}
>
<
ProfileAddressIcon
address=
{
address
}
isAutoConnectDisabled=
{
isAutoConnectDisabled
}
/>
<
ProfileAddressIcon
address=
{
address
}
isAutoConnectDisabled=
{
isAutoConnectDisabled
}
/>
<
Text
display=
{
{
base
:
'
none
'
,
md
:
'
block
'
}
}
>
{
text
}
</
Text
>
<
Box
display=
{
{
base
:
'
none
'
,
md
:
'
block
'
}
}
>
{
text
}
</
Box
>
</
HStack
>
</
HStack
>
);
);
}
}
...
@@ -64,7 +64,7 @@ const ProfileButton = ({ profileQuery, size, variant, onClick, isPending }: Prop
...
@@ -64,7 +64,7 @@ const ProfileButton = ({ profileQuery, size, variant, onClick, isPending }: Prop
return
(
return
(
<
HStack
gap=
{
2
}
>
<
HStack
gap=
{
2
}
>
<
IconSvg
name=
"profile"
boxSize=
{
5
}
/>
<
IconSvg
name=
"profile"
boxSize=
{
5
}
/>
<
Text
display=
{
{
base
:
'
none
'
,
md
:
'
block
'
}
}
>
{
getUserHandle
(
data
.
email
)
}
</
Text
>
<
Box
display=
{
{
base
:
'
none
'
,
md
:
'
block
'
}
}
>
{
getUserHandle
(
data
.
email
)
}
</
Box
>
</
HStack
>
</
HStack
>
);
);
}
}
...
...
ui/snippets/profile/ProfileDesktop.tsx
View file @
9cc3d536
...
@@ -5,7 +5,7 @@ import React from 'react';
...
@@ -5,7 +5,7 @@ import React from 'react';
import
useFetchProfileInfo
from
'
lib/hooks/useFetchProfileInfo
'
;
import
useFetchProfileInfo
from
'
lib/hooks/useFetchProfileInfo
'
;
import
Popover
from
'
ui/shared/chakra/Popover
'
;
import
Popover
from
'
ui/shared/chakra/Popover
'
;
import
AuthModal
from
'
ui/snippets/auth/AuthModal
'
;
import
AuthModal
from
'
ui/snippets/auth/AuthModal
'
;
import
useSignInWithWallet
from
'
ui/snippets/auth/
screens/
useSignInWithWallet
'
;
import
useSignInWithWallet
from
'
ui/snippets/auth/useSignInWithWallet
'
;
import
ProfileButton
from
'
./ProfileButton
'
;
import
ProfileButton
from
'
./ProfileButton
'
;
import
ProfileMenuContent
from
'
./ProfileMenuContent
'
;
import
ProfileMenuContent
from
'
./ProfileMenuContent
'
;
...
...
ui/snippets/profile/ProfileMenuContent.tsx
View file @
9cc3d536
...
@@ -9,6 +9,7 @@ import { route } from 'nextjs-routes';
...
@@ -9,6 +9,7 @@ import { route } from 'nextjs-routes';
import
config
from
'
configs/app
'
;
import
config
from
'
configs/app
'
;
import
{
useMarketplaceContext
}
from
'
lib/contexts/marketplace
'
;
import
{
useMarketplaceContext
}
from
'
lib/contexts/marketplace
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
useLogout
from
'
ui/snippets/auth/useLogout
'
;
import
ProfileMenuNavLink
from
'
./ProfileMenuNavLink
'
;
import
ProfileMenuNavLink
from
'
./ProfileMenuNavLink
'
;
import
ProfileMenuWallet
from
'
./ProfileMenuWallet
'
;
import
ProfileMenuWallet
from
'
./ProfileMenuWallet
'
;
...
@@ -50,6 +51,7 @@ interface Props {
...
@@ -50,6 +51,7 @@ interface Props {
const
ProfileMenuContent
=
({
data
,
onClose
}:
Props
)
=>
{
const
ProfileMenuContent
=
({
data
,
onClose
}:
Props
)
=>
{
const
{
isAutoConnectDisabled
}
=
useMarketplaceContext
();
const
{
isAutoConnectDisabled
}
=
useMarketplaceContext
();
const
alertBgColor
=
useColorModeValue
(
'
orange.100
'
,
'
orange.900
'
);
const
alertBgColor
=
useColorModeValue
(
'
orange.100
'
,
'
orange.900
'
);
const
logout
=
useLogout
();
return
(
return
(
<
Box
>
<
Box
>
...
@@ -101,7 +103,7 @@ const ProfileMenuContent = ({ data, onClose }: Props) => {
...
@@ -101,7 +103,7 @@ const ProfileMenuContent = ({ data, onClose }: Props) => {
<
ProfileMenuNavLink
<
ProfileMenuNavLink
text=
"Sign out"
text=
"Sign out"
icon=
"sign_out"
icon=
"sign_out"
onClick=
{
onClose
}
onClick=
{
logout
}
/>
/>
</
Box
>
</
Box
>
);
);
...
...
ui/snippets/profile/ProfileMobile.tsx
View file @
9cc3d536
...
@@ -4,8 +4,8 @@ import React from 'react';
...
@@ -4,8 +4,8 @@ import React from 'react';
import
useFetchProfileInfo
from
'
lib/hooks/useFetchProfileInfo
'
;
import
useFetchProfileInfo
from
'
lib/hooks/useFetchProfileInfo
'
;
import
AuthModal
from
'
ui/snippets/auth/AuthModal
'
;
import
AuthModal
from
'
ui/snippets/auth/AuthModal
'
;
import
useSignInWithWallet
from
'
ui/snippets/auth/useSignInWithWallet
'
;
import
useSignInWithWallet
from
'
../auth/screens/useSignInWithWallet
'
;
import
ProfileButton
from
'
./ProfileButton
'
;
import
ProfileButton
from
'
./ProfileButton
'
;
import
ProfileMenuContent
from
'
./ProfileMenuContent
'
;
import
ProfileMenuContent
from
'
./ProfileMenuContent
'
;
...
...
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