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';
|
2020-09-02 22:08:37 +02:00
|
|
|
import Card from 'component/common/card';
|
|
|
|
import I18nMessage from 'component/i18nMessage';
|
|
|
|
import LbcSymbol from 'component/common/lbc-symbol';
|
2018-09-26 02:12:07 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
closeModal: () => void,
|
|
|
|
error: ?string,
|
|
|
|
rewardIsPending: boolean,
|
2021-10-21 22:21:51 +02:00
|
|
|
submitRewardCode: (string) => void,
|
2018-09-26 02:12:07 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
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 (
|
2020-09-02 22:08:37 +02:00
|
|
|
<Modal isOpen contentLabel={__('Enter reward code')} type="card" onAborted={closeModal}>
|
|
|
|
<Card
|
|
|
|
title={__('Enter reward code')}
|
|
|
|
subtitle={
|
|
|
|
<I18nMessage
|
|
|
|
tokens={{
|
|
|
|
lbc: <LbcSymbol prefix={__('Redeem a custom reward code for')} />,
|
|
|
|
learn_more: (
|
2021-10-21 22:21:51 +02:00
|
|
|
<Button
|
|
|
|
button="link"
|
|
|
|
href="https://odysee.com/@OdyseeHelp:b/rewards-verification:3#reward-code"
|
|
|
|
label={__('Learn more')}
|
|
|
|
/>
|
2020-09-02 22:08:37 +02:00
|
|
|
),
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
%lbc%. %learn_more%.
|
|
|
|
</I18nMessage>
|
|
|
|
}
|
|
|
|
actions={
|
|
|
|
<>
|
|
|
|
<Form onSubmit={this.handleSubmit}>
|
|
|
|
<FormField
|
|
|
|
autoFocus
|
|
|
|
type="text"
|
|
|
|
name="reward-code"
|
|
|
|
inputButton={
|
|
|
|
<Button
|
|
|
|
button="primary"
|
|
|
|
type="submit"
|
|
|
|
disabled={!rewardCode || rewardIsPending}
|
|
|
|
label={rewardIsPending ? __('Redeeming') : __('Redeem')}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
label={__('Code')}
|
|
|
|
placeholder="0123abc"
|
|
|
|
error={error}
|
|
|
|
value={rewardCode}
|
2021-10-21 22:21:51 +02:00
|
|
|
onChange={(e) => this.setState({ rewardCode: e.target.value })}
|
2020-09-02 22:08:37 +02:00
|
|
|
/>
|
|
|
|
</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;
|