2018-09-26 19:48:07 +02:00
|
|
|
// @flow
|
2017-12-21 22:08:54 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { Modal } from 'modal/modal';
|
2018-03-26 23:32:43 +02:00
|
|
|
import Button from 'component/button';
|
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-09-26 19:48:07 +02:00
|
|
|
type Props = {
|
|
|
|
phone: ?number,
|
|
|
|
user: {
|
|
|
|
phone_number: ?number,
|
|
|
|
},
|
|
|
|
closeModal: () => void,
|
|
|
|
};
|
|
|
|
|
|
|
|
class ModalPhoneCollection extends React.PureComponent<Props> {
|
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
|
|
|
|
2018-04-05 23:26:20 +02:00
|
|
|
const cancelButton = <Button button="link" 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
|
|
|
}
|
2018-09-26 19:48:07 +02:00
|
|
|
return 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 (
|
2019-01-08 19:48:09 +01:00
|
|
|
<Modal type="custom" isOpen contentLabel="Phone">
|
|
|
|
{this.renderInner()}
|
2017-12-07 19:07:30 +01:00
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-11 07:00:51 +01:00
|
|
|
export default ModalPhoneCollection;
|