-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move logic to effect for reset private key component
- Loading branch information
Showing
2 changed files
with
30 additions
and
23 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
libs/dsb-client-gateway/ui/login/src/lib/ResetPrivateKey/ResetPrivateKey.effects.tsx
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,27 @@ | ||
import { useContext } from 'react'; | ||
import { UserDataContext } from '@dsb-client-gateway/ui/login'; | ||
import Swal from 'sweetalert2'; | ||
import { theme } from '@dsb-client-gateway/ui/utils'; | ||
import { AccountStatusEnum } from '../check-account-status/check-account-status'; | ||
|
||
export const useResetPrivateKey = () => { | ||
const {userData, setUserData} = useContext(UserDataContext); | ||
|
||
const resetPrivateKeyHandler = () => { | ||
Swal.fire( { | ||
icon: 'warning', | ||
iconColor: theme.palette.warning.main, | ||
title: 'Reset private key', | ||
text: 'Please confirm to reset private key', | ||
showCancelButton: true, | ||
showConfirmButton: true, | ||
confirmButtonText: 'Confirm' | ||
}).then((result) => { | ||
if (result.isConfirmed) { | ||
setUserData({...userData, accountStatus: AccountStatusEnum.NotSetPrivateKey}); | ||
} | ||
}) | ||
}; | ||
|
||
return {resetPrivateKeyHandler} | ||
} |
26 changes: 3 additions & 23 deletions
26
libs/dsb-client-gateway/ui/login/src/lib/ResetPrivateKey/ResetPrivateKey.tsx
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