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-22 08:09:11 +01:00
|
|
|
import UserPhoneNew from 'component/userPhoneNew';
|
|
|
|
import UserPhoneVerify from 'component/userPhoneVerify';
|
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() {
|
2018-01-15 14:32:01 +01:00
|
|
|
const { closeModal, phone, user } = this.props;
|
2017-12-07 19:07:30 +01:00
|
|
|
|
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
|
|
|
|
2018-01-15 14:32:01 +01:00
|
|
|
if (!user.phone_number && !phone) {
|
2018-01-22 08:09:11 +01:00
|
|
|
return <UserPhoneNew cancelButton={cancelButton} />;
|
2018-01-15 14:32:01 +01:00
|
|
|
} else if (!user.phone_number) {
|
2018-01-22 08:09:11 +01:00
|
|
|
return <UserPhoneVerify 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;
|