lbry-desktop/ui/modal/modalPhoneCollection/view.jsx

61 lines
1.4 KiB
React
Raw Normal View History

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