lbry-desktop/src/ui/modal/modalRewardCode/view.jsx

81 lines
2 KiB
React
Raw Normal View History

2018-09-26 02:12:07 +02:00
// @flow
import * as React from 'react';
2019-07-21 23:31:22 +02:00
import { FormField, Form } 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-07-21 23:31:22 +02:00
<Form onSubmit={this.handleSubmit}>
<p>
{__('Redeem a custom reward code for LBC')}
{'. '}
2019-05-07 23:38:29 +02:00
<Button button="link" href="https://lbry.com/faq/rewards#reward-code" label={__('Learn more')} />.
</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={
2019-07-21 23:31:22 +02:00
<Button
button="primary"
2019-07-24 16:35:12 +02:00
type="submit"
2019-02-13 17:27:20 +01:00
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;