2017-12-21 22:08:54 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { Modal } from 'modal/modal';
|
|
|
|
import Link from 'component/link/index';
|
2018-01-11 07:16:03 +01:00
|
|
|
import UserFieldNew from 'component/userFieldNew';
|
|
|
|
import UserFieldVerify from 'component/userFieldVerify';
|
2017-12-07 19:07:30 +01:00
|
|
|
|
2018-01-11 07:00:51 +01:00
|
|
|
class ModalPhoneCollection extends React.PureComponent {
|
2017-12-07 19:07:30 +01:00
|
|
|
renderInner() {
|
|
|
|
const { closeModal, email, user } = this.props;
|
|
|
|
|
2017-12-21 22:08:54 +01:00
|
|
|
const cancelButton = <Link button="text" onClick={closeModal} label={__('Not Now')} />;
|
2017-12-07 19:07:30 +01:00
|
|
|
|
|
|
|
if (!user.has_verified_email && !email) {
|
2018-01-11 07:16:03 +01:00
|
|
|
return <UserFieldNew cancelButton={cancelButton} />;
|
2017-12-07 19:07:30 +01:00
|
|
|
} else if (!user.has_verified_email) {
|
2018-01-11 07:16:03 +01:00
|
|
|
return <UserFieldVerify cancelButton={cancelButton} />;
|
2017-12-07 19:07:30 +01:00
|
|
|
}
|
2017-12-21 22:08:54 +01:00
|
|
|
closeModal();
|
2017-12-07 19:07:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { user } = this.props;
|
|
|
|
|
2017-12-21 22:08:54 +01:00
|
|
|
// this shouldn't happen
|
2017-12-07 19:07:30 +01:00
|
|
|
if (!user) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2018-01-11 07:16:03 +01:00
|
|
|
<Modal type="custom" isOpen contentLabel="Phone">
|
2017-12-07 19:07:30 +01:00
|
|
|
<section>
|
2018-01-11 07:16:03 +01:00
|
|
|
<h3 className="modal__header">Verify Your Phone</h3>
|
2017-12-07 19:07:30 +01:00
|
|
|
{this.renderInner()}
|
|
|
|
</section>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-11 07:00:51 +01:00
|
|
|
export default ModalPhoneCollection;
|