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() {
|
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) {
|
|
|
|
return <UserFieldNew cancelButton={cancelButton} fieldType="phone" />;
|
|
|
|
} else if (!user.phone_number) {
|
|
|
|
return <UserFieldVerify cancelButton={cancelButton} fieldType="phone" />;
|
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;
|