-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Go to profile page or not after connect wallet
- Loading branch information
Showing
6 changed files
with
60 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useModal } from '@node-real/walletkit'; | ||
import { useState } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { useAccount } from 'wagmi'; | ||
|
||
/** | ||
* 'HOME': NOT REDIRECTED | ||
* 'GO_TO_PROFILE': Go To profile page after connect wallet | ||
*/ | ||
type Tag = 'DEFAULT' | 'GO_TO_PROFILE'; | ||
|
||
export function useAppWallet() { | ||
const navigate = useNavigate(); | ||
const [tag, setTag] = useState<Tag>('DEFAULT'); | ||
|
||
const { address } = useAccount({ | ||
onConnect() { | ||
if (tag === 'DEFAULT') return; | ||
|
||
navigate('/profile?tab=uploaded'); | ||
}, | ||
}); | ||
|
||
const { isOpen, onOpen } = useModal(); | ||
|
||
return { | ||
address, | ||
isOpen, | ||
onOpen(tag: Tag = 'DEFAULT') { | ||
setTag(tag); | ||
onOpen(); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters