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

51 lines
1.2 KiB
React
Raw Permalink Normal View History

2018-09-26 19:48:07 +02:00
// @flow
2020-08-26 22:28:33 +02:00
import React 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> {
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() {
2020-08-26 22:28:33 +02:00
const { user, closeModal } = this.props;
// this shouldn't happen
if (!user) {
return null;
}
return (
2020-08-26 22:28:33 +02:00
<Modal type="card" isOpen contentLabel="Phone" onAborted={closeModal}>
2019-01-08 19:48:09 +01:00
{this.renderInner()}
</Modal>
);
}
}
export default ModalPhoneCollection;