lbry-desktop/src/renderer/modal/modalPhoneCollection/view.jsx

47 lines
1 KiB
React
Raw Normal View History

2018-09-26 19:48:07 +02:00
// @flow
import React from 'react';
import { Modal } from 'modal/modal';
2018-03-26 23:32:43 +02:00
import Button from 'component/button';
import UserPhoneNew from 'component/userPhoneNew';
import UserPhoneVerify from 'component/userPhoneVerify';
2018-09-26 19:48:07 +02:00
type Props = {
phone: ?number,
user: {
phone_number: ?number,
},
closeModal: () => void,
};
class ModalPhoneCollection extends React.PureComponent<Props> {
renderInner() {
2018-01-15 14:32:01 +01:00
const { closeModal, phone, user } = this.props;
const cancelButton = <Button button="link" onClick={closeModal} label={__('Not Now')} />;
2018-01-15 14:32:01 +01:00
if (!user.phone_number && !phone) {
return <UserPhoneNew cancelButton={cancelButton} />;
2018-01-15 14:32:01 +01:00
} else if (!user.phone_number) {
return <UserPhoneVerify cancelButton={cancelButton} />;
}
2018-09-26 19:48:07 +02:00
return closeModal();
}
render() {
const { user } = this.props;
// this shouldn't happen
if (!user) {
return null;
}
return (
2019-01-08 19:48:09 +01:00
<Modal type="custom" isOpen contentLabel="Phone">
{this.renderInner()}
</Modal>
);
}
}
export default ModalPhoneCollection;