-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(refactor): refactor verify magic link (#6175)
- Loading branch information
1 parent
34a965e
commit 9a159ce
Showing
4 changed files
with
47 additions
and
63 deletions.
There are no files selected for viewing
26 changes: 9 additions & 17 deletions
26
packages/blockchain-wallet-v4-frontend/src/scenes/Login/VerifyMagicLink/index.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 |
---|---|---|
@@ -1,28 +1,20 @@ | ||
import React from 'react' | ||
import { connect } from 'react-redux' | ||
|
||
import { selectors } from 'data' | ||
import { getAuthorizeVerifyDevice } from 'data/auth/selectors' | ||
import { useRemote } from 'hooks' | ||
|
||
import { Props } from '..' | ||
import Error from './template.error' | ||
import Loading from './template.loading' | ||
import Success from './template.success' | ||
|
||
class VerifyMagicLink extends React.PureComponent<Props> { | ||
render() { | ||
return this.props.data.cata({ | ||
Failure: (val) => <Error error={val} />, | ||
Loading: () => <Loading />, | ||
NotAsked: () => <Loading />, | ||
Success: (val) => <Success {...this.props} {...val} /> | ||
}) | ||
} | ||
} | ||
const VerifyMagicLink = (props: Props) => { | ||
const { data, error, isLoading, isNotAsked } = useRemote(getAuthorizeVerifyDevice) | ||
|
||
const mapStateToProps = (state) => ({ | ||
data: selectors.auth.getAuthorizeVerifyDevice(state) | ||
}) | ||
if (isLoading || isNotAsked) return <Loading /> | ||
|
||
const connector = connect(mapStateToProps) | ||
if (error) return <Error error={error} /> | ||
return <Success {...props} {...data} /> | ||
} | ||
|
||
export default connector(VerifyMagicLink) | ||
export default VerifyMagicLink |
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