lbry-desktop/ui/component/userPhoneVerify/view.jsx

81 lines
2 KiB
React
Raw Normal View History

2019-03-18 01:09:50 -04:00
// @flow
import * as React from 'react';
2018-03-26 14:32:43 -07:00
import Button from 'component/button';
2019-02-13 12:27:20 -04:00
import { Form, FormField, Submit } from 'component/common/form';
2017-06-02 19:09:52 -04:00
2019-03-18 01:09:50 -04:00
type Props = {
verifyUserPhone: string => void,
resetPhone: () => void,
cancelButton: React.Node,
phoneErrorMessage: string,
phone: string,
countryCode: string,
};
type State = {
code: string,
};
class UserPhoneVerify extends React.PureComponent<Props, State> {
constructor(props: Props) {
2017-06-02 19:09:52 -04:00
super(props);
this.state = {
code: '',
2017-06-02 19:09:52 -04:00
};
}
2019-03-18 01:09:50 -04:00
handleCodeChanged(event: SyntheticInputEvent<*>) {
2017-06-02 19:09:52 -04:00
this.setState({
2017-07-18 19:00:13 -04:00
code: String(event.target.value).trim(),
2017-06-02 19:09:52 -04:00
});
}
handleSubmit() {
const { code } = this.state;
this.props.verifyUserPhone(code);
2017-06-02 19:09:52 -04:00
}
reset() {
const { resetPhone } = this.props;
resetPhone();
}
2017-06-02 19:09:52 -04:00
render() {
const { cancelButton, phoneErrorMessage, phone, countryCode } = this.props;
2017-06-08 17:15:34 -04:00
return (
2019-01-08 13:48:09 -05:00
<React.Fragment>
2019-07-21 17:31:22 -04:00
<p>
{' '}
{__(`Please enter the verification code sent to +${countryCode}${phone}. Didn't receive it? `)}
<Button button="link" onClick={this.reset.bind(this)} label="Go back." />
</p>
<Form onSubmit={this.handleSubmit.bind(this)}>
2019-02-13 12:27:20 -04:00
<FormField
2019-03-20 17:43:00 -04:00
type="text"
name="code"
placeholder="1234"
2019-02-13 12:27:20 -04:00
value={this.state.code}
onChange={event => {
this.handleCodeChanged(event);
}}
label={__('Verification Code')}
error={phoneErrorMessage}
inputButton={<Submit label={__('Verify')} />}
/>
2019-01-08 13:48:09 -05:00
2019-03-20 17:43:00 -04:00
<div className="card__actions">{cancelButton}</div>
2019-01-08 13:48:09 -05:00
</Form>
2019-03-20 17:43:00 -04:00
<p className="help">
2019-05-07 17:38:29 -04:00
{__('Email')} <Button button="link" href="mailto:help@lbry.com" label="help@lbry.com" /> or join our{' '}
<Button button="link" href="https://chat.lbry.com" label="chat" />{' '}
{__('if you encounter any trouble with your code.')}
</p>
2019-01-08 13:48:09 -05:00
</React.Fragment>
2017-06-08 17:15:34 -04:00
);
2017-06-02 19:09:52 -04:00
}
}
export default UserPhoneVerify;