-
Notifications
You must be signed in to change notification settings - Fork 461
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add social login option to onboard module
- Loading branch information
1 parent
146dc8e
commit 0b51955
Showing
4 changed files
with
74 additions
and
31 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,42 @@ | ||
import { PasswordRecovery } from '@/components/common/SocialSigner/PasswordRecovery' | ||
import TxModalDialog from '@/components/common/TxModalDialog' | ||
import useSocialWallet from '@/hooks/wallets/mpc/useSocialWallet' | ||
import ExternalStore from '@/services/ExternalStore' | ||
|
||
const { useStore: useCloseCallback, setStore: setCloseCallback } = new ExternalStore<() => void>() | ||
|
||
export const open = (cb: () => void) => { | ||
setCloseCallback(() => cb) | ||
} | ||
|
||
export const close = () => { | ||
setCloseCallback(undefined) | ||
} | ||
|
||
const PasswordRecoveryModal = () => { | ||
const socialWalletService = useSocialWallet() | ||
const closeCallback = useCloseCallback() | ||
const open = !!closeCallback | ||
|
||
const handleClose = () => { | ||
closeCallback?.() | ||
setCloseCallback(undefined) | ||
close() | ||
} | ||
|
||
const recoverPassword = async (password: string, storeDeviceFactor: boolean) => { | ||
if (!socialWalletService) return | ||
|
||
await socialWalletService.recoverAccountWithPassword(password, storeDeviceFactor) | ||
} | ||
|
||
if (!open) return null | ||
|
||
return ( | ||
<TxModalDialog open={open} onClose={handleClose} fullWidth sx={{ zIndex: '10000 !important', top: '0 !important' }}> | ||
<PasswordRecovery recoverFactorWithPassword={recoverPassword} onSuccess={handleClose} /> | ||
</TxModalDialog> | ||
) | ||
} | ||
|
||
export default PasswordRecoveryModal |
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