2018-09-26 13:48:07 -04:00
|
|
|
// @flow
|
2019-04-03 00:56:58 -05:00
|
|
|
import React, { Suspense } from 'react';
|
2017-12-21 18:08:54 -03:00
|
|
|
import { Modal } from 'modal/modal';
|
2018-03-26 14:32:43 -07:00
|
|
|
import Button from 'component/button';
|
2018-01-21 23:09:11 -08:00
|
|
|
import UserPhoneVerify from 'component/userPhoneVerify';
|
2019-11-07 14:39:22 -05:00
|
|
|
import UserPhoneNew from 'component/userPhoneNew';
|
2019-05-10 01:08:48 -04:00
|
|
|
import { Redirect } from 'react-router';
|
2017-12-07 13:07:30 -05:00
|
|
|
|
2018-09-26 13:48:07 -04:00
|
|
|
type Props = {
|
|
|
|
phone: ?number,
|
|
|
|
user: {
|
2019-05-10 01:08:48 -04:00
|
|
|
is_identity_verified: boolean,
|
2018-09-26 13:48:07 -04:00
|
|
|
},
|
|
|
|
closeModal: () => void,
|
2019-04-04 17:05:23 -04:00
|
|
|
history: { push: string => void },
|
2018-09-26 13:48:07 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class ModalPhoneCollection extends React.PureComponent<Props> {
|
2019-01-14 13:40:06 -05:00
|
|
|
getTitle() {
|
|
|
|
const { user, phone } = this.props;
|
|
|
|
|
2019-05-10 01:08:48 -04:00
|
|
|
if (!user.is_identity_verified && !phone) {
|
2019-01-14 13:40:06 -05:00
|
|
|
return __('Enter Your Phone Number');
|
|
|
|
}
|
2019-05-10 01:08:48 -04:00
|
|
|
|
2019-01-14 13:40:06 -05:00
|
|
|
return __('Enter The Verification Code');
|
|
|
|
}
|
|
|
|
|
2017-12-07 13:07:30 -05:00
|
|
|
renderInner() {
|
2019-05-10 01:08:48 -04:00
|
|
|
const { closeModal, phone, user } = this.props;
|
2017-12-07 13:07:30 -05:00
|
|
|
|
2018-04-05 17:26:20 -04:00
|
|
|
const cancelButton = <Button button="link" onClick={closeModal} label={__('Not Now')} />;
|
2017-12-07 13:07:30 -05:00
|
|
|
|
2019-05-10 01:08:48 -04:00
|
|
|
if (!user.is_identity_verified && !phone) {
|
2019-11-07 14:39:22 -05:00
|
|
|
return <UserPhoneNew cancelButton={cancelButton} />;
|
2019-05-10 01:08:48 -04:00
|
|
|
} else if (!user.is_identity_verified) {
|
2018-01-21 23:09:11 -08:00
|
|
|
return <UserPhoneVerify cancelButton={cancelButton} />;
|
2017-12-07 13:07:30 -05:00
|
|
|
}
|
2019-04-04 17:05:23 -04:00
|
|
|
|
2019-05-10 01:08:48 -04:00
|
|
|
closeModal();
|
|
|
|
return <Redirect to="/$/rewards" />;
|
2017-12-07 13:07:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { user } = this.props;
|
|
|
|
|
2017-12-21 18:08:54 -03:00
|
|
|
// this shouldn't happen
|
2017-12-07 13:07:30 -05:00
|
|
|
if (!user) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2019-01-14 13:40:06 -05:00
|
|
|
<Modal type="custom" isOpen contentLabel="Phone" title={this.getTitle()}>
|
2019-01-08 13:48:09 -05:00
|
|
|
{this.renderInner()}
|
2017-12-07 13:07:30 -05:00
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-10 01:08:48 -04:00
|
|
|
export default ModalPhoneCollection;
|