-
-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(profile): new profile design and addition fields [unstable]
- Loading branch information
Showing
16 changed files
with
556 additions
and
72 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
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,79 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { connect } from 'react-redux' | ||
import { observer } from 'mobx-react' | ||
import { observable } from 'mobx' | ||
|
||
import { hideModal } from 'actions/common' | ||
|
||
import Input from 'components/Input' | ||
import Button from 'components/Button' | ||
import BaseModal from 'containers/Modals/BaseModal' | ||
|
||
import axios from 'axios' | ||
import helpers from 'lib/helpers' | ||
|
||
@observer | ||
class PasswordPromptModal extends React.Component { | ||
@observable confirmPassword = '' | ||
onVerifyPassword = e => { | ||
e.preventDefault() | ||
axios | ||
.post('/api/v2/accounts/profile/mfa/disable', { | ||
confirmPassword: this.confirmPassword | ||
}) | ||
.then(res => { | ||
this.props.hideModal() | ||
if (this.props.onVerifyComplete) this.props.onVerifyComplete(true) | ||
}) | ||
.catch(error => { | ||
let errMessage = 'An Error has occurred.' | ||
if (error.response && error.response.data && error.response.data.error) errMessage = error.response.data.error | ||
helpers.UI.showSnackbar(errMessage, true) | ||
if (this.props.onVerifyComplete) this.props.onVerifyComplete(false) | ||
}) | ||
} | ||
render () { | ||
const { titleOverride, textOverride } = this.props | ||
return ( | ||
<BaseModal options={{ bgclose: false }}> | ||
<div> | ||
<h2>{titleOverride || 'Confirm Password'}</h2> | ||
<p>{textOverride || 'Please confirm your password.'}</p> | ||
</div> | ||
<div className={'uk-margin-medium-bottom'}> | ||
<label>Current Password</label> | ||
<Input name={'current-password'} type={'password'} onChange={val => (this.confirmPassword = val)} /> | ||
</div> | ||
<div style={{ display: 'flex', justifyContent: 'flex-end' }}> | ||
<Button text={'Cancel'} small={true} flat={true} waves={false} onClick={() => this.props.hideModal()} /> | ||
<Button | ||
text={'Verify Password'} | ||
style={'primary'} | ||
small={true} | ||
waves={true} | ||
onClick={e => this.onVerifyPassword(e)} | ||
/> | ||
</div> | ||
</BaseModal> | ||
) | ||
} | ||
} | ||
|
||
PasswordPromptModal.propTypes = { | ||
user: PropTypes.object.isRequired, | ||
titleOverride: PropTypes.string, | ||
textOverride: PropTypes.string, | ||
onVerifyComplete: PropTypes.func.isRequired, | ||
hideModal: PropTypes.func.isRequired | ||
} | ||
|
||
const mapStateToProps = state => ({}) | ||
|
||
export default connect(mapStateToProps, { hideModal })(PasswordPromptModal) |
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
Oops, something went wrong.