2019-03-18 06:09:50 +01:00
|
|
|
// @flow
|
|
|
|
import * as React from 'react';
|
2018-03-26 23:32:43 +02:00
|
|
|
import Button from 'component/button';
|
2019-02-13 17:27:20 +01:00
|
|
|
import { Form, FormField, Submit } from 'component/common/form';
|
2020-01-09 20:03:47 +01:00
|
|
|
import I18nMessage from 'component/i18nMessage';
|
2020-08-26 22:28:33 +02:00
|
|
|
import Card from 'component/common/card';
|
2017-06-03 01:09:52 +02:00
|
|
|
|
2019-03-18 06:09:50 +01:00
|
|
|
type Props = {
|
2021-03-03 20:23:42 +01:00
|
|
|
verifyUserPhone: (string) => void,
|
2019-03-18 06:09:50 +01:00
|
|
|
resetPhone: () => void,
|
|
|
|
phoneErrorMessage: string,
|
|
|
|
phone: string,
|
|
|
|
countryCode: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
type State = {
|
|
|
|
code: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
class UserPhoneVerify extends React.PureComponent<Props, State> {
|
|
|
|
constructor(props: Props) {
|
2017-06-03 01:09:52 +02:00
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
2017-12-21 22:08:54 +01:00
|
|
|
code: '',
|
2017-06-03 01:09:52 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-03-18 06:09:50 +01:00
|
|
|
handleCodeChanged(event: SyntheticInputEvent<*>) {
|
2017-06-03 01:09:52 +02:00
|
|
|
this.setState({
|
2017-07-19 01:00:13 +02:00
|
|
|
code: String(event.target.value).trim(),
|
2017-06-03 01:09:52 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-09-11 03:25:24 +02:00
|
|
|
handleSubmit() {
|
|
|
|
const { code } = this.state;
|
2018-01-22 08:09:11 +01:00
|
|
|
this.props.verifyUserPhone(code);
|
2017-06-03 01:09:52 +02:00
|
|
|
}
|
|
|
|
|
2018-01-23 00:26:34 +01:00
|
|
|
reset() {
|
|
|
|
const { resetPhone } = this.props;
|
|
|
|
resetPhone();
|
|
|
|
}
|
|
|
|
|
2017-06-03 01:09:52 +02:00
|
|
|
render() {
|
2020-08-26 22:28:33 +02:00
|
|
|
const { phoneErrorMessage, phone, countryCode } = this.props;
|
2017-06-08 23:15:34 +02:00
|
|
|
return (
|
2020-08-26 22:28:33 +02:00
|
|
|
<Card
|
|
|
|
title={__('Enter the verification code')}
|
|
|
|
subtitle={
|
|
|
|
<>
|
|
|
|
{__(`Please enter the verification code sent to +${countryCode}${phone}. Didn't receive it? `)}
|
|
|
|
<Button button="link" onClick={this.reset.bind(this)} label={__('Go back.')} />
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
actions={
|
|
|
|
<>
|
|
|
|
<Form onSubmit={this.handleSubmit.bind(this)}>
|
|
|
|
<FormField
|
|
|
|
type="text"
|
|
|
|
name="code"
|
|
|
|
placeholder="1234"
|
|
|
|
value={this.state.code}
|
2021-03-03 20:23:42 +01:00
|
|
|
onChange={(event) => {
|
2020-08-26 22:28:33 +02:00
|
|
|
this.handleCodeChanged(event);
|
|
|
|
}}
|
|
|
|
label={__('Verification Code')}
|
|
|
|
error={phoneErrorMessage}
|
|
|
|
inputButton={<Submit label={__('Verify')} />}
|
|
|
|
/>
|
|
|
|
</Form>
|
|
|
|
<p className="help">
|
|
|
|
<I18nMessage
|
|
|
|
tokens={{
|
2021-03-03 20:23:42 +01:00
|
|
|
help_link: <Button button="link" href="mailto:help@odysee.com" label="help@odysee.com" />,
|
2020-08-26 22:28:33 +02:00
|
|
|
chat_link: <Button button="link" href="https://chat.lbry.com" label={__('chat')} />,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Email %help_link% or join our %chat_link% if you encounter any trouble with your code.
|
|
|
|
</I18nMessage>
|
|
|
|
</p>
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
/>
|
2017-06-08 23:15:34 +02:00
|
|
|
);
|
2017-06-03 01:09:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-22 08:09:11 +01:00
|
|
|
export default UserPhoneVerify;
|