2018-09-26 13:48:07 -04:00
|
|
|
// @flow
|
2020-08-26 16:28:33 -04:00
|
|
|
import React 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> {
|
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() {
|
2020-08-26 16:28:33 -04:00
|
|
|
const { user, closeModal } = this.props;
|
2017-12-07 13:07:30 -05:00
|
|
|
|
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 (
|
2020-08-26 16:28:33 -04:00
|
|
|
<Modal type="card" isOpen contentLabel="Phone" onAborted={closeModal}>
|
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;
|