2018-09-26 02:12:07 +02:00
|
|
|
// @flow
|
|
|
|
import * as React from 'react';
|
2019-02-13 17:27:20 +01:00
|
|
|
import { FormField, Form, Submit } from 'component/common/form';
|
2018-09-26 02:12:07 +02:00
|
|
|
import { Modal } from 'modal/modal';
|
|
|
|
import Button from 'component/button';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
closeModal: () => void,
|
|
|
|
error: ?string,
|
|
|
|
rewardIsPending: boolean,
|
|
|
|
submitRewardCode: string => void,
|
|
|
|
};
|
|
|
|
|
|
|
|
type State = {
|
|
|
|
rewardCode: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
class ModalRewardCode extends React.PureComponent<Props, State> {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
rewardCode: '',
|
|
|
|
};
|
|
|
|
|
|
|
|
(this: any).handleSubmit = this.handleSubmit.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleSubmit() {
|
|
|
|
const { rewardCode } = this.state;
|
|
|
|
const { submitRewardCode } = this.props;
|
|
|
|
submitRewardCode(rewardCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { closeModal, rewardIsPending, error } = this.props;
|
|
|
|
const { rewardCode } = this.state;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
isOpen
|
2018-09-26 19:48:07 +02:00
|
|
|
title={__('Enter Reward Code')}
|
2018-09-26 02:12:07 +02:00
|
|
|
contentLabel={__('Enter Reward Code')}
|
2019-02-13 17:27:20 +01:00
|
|
|
type="custom"
|
2018-09-26 02:12:07 +02:00
|
|
|
onAborted={closeModal}
|
|
|
|
>
|
2019-02-13 17:27:20 +01:00
|
|
|
<Form className="card__content" onSubmit={this.handleSubmit}>
|
2019-01-14 19:40:06 +01:00
|
|
|
<p>
|
|
|
|
{__('Redeem a custom reward code for LBC')}
|
|
|
|
{'. '}
|
|
|
|
<Button
|
|
|
|
button="link"
|
2019-03-20 22:43:00 +01:00
|
|
|
href="https://lbry.com/faq/rewards#reward-code"
|
2019-01-14 19:40:06 +01:00
|
|
|
label={__('Learn more')}
|
2019-03-05 05:46:57 +01:00
|
|
|
/>
|
|
|
|
.
|
2019-01-14 19:40:06 +01:00
|
|
|
</p>
|
2019-02-13 17:27:20 +01:00
|
|
|
<FormField
|
|
|
|
autoFocus
|
|
|
|
type="text"
|
2019-02-20 06:20:29 +01:00
|
|
|
name="reward-code"
|
2019-02-13 17:27:20 +01:00
|
|
|
inputButton={
|
|
|
|
<Submit
|
|
|
|
disabled={!rewardCode || rewardIsPending}
|
|
|
|
label={rewardIsPending ? __('Redeeming') : __('Redeem')}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
label={__('Code')}
|
|
|
|
placeholder="0123abc"
|
|
|
|
error={error}
|
|
|
|
value={rewardCode}
|
|
|
|
onChange={e => this.setState({ rewardCode: e.target.value })}
|
|
|
|
/>
|
|
|
|
</Form>
|
|
|
|
<div className="card__actions">
|
|
|
|
<Button button="link" label={__('Cancel')} onClick={closeModal} />
|
|
|
|
</div>
|
2018-09-26 02:12:07 +02:00
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ModalRewardCode;
|