2017-07-27 16:48:18 +02:00
|
|
|
import React from "react";
|
|
|
|
import Link from "component/link";
|
2017-08-08 00:13:58 +02:00
|
|
|
import FormFieldPrice from "component/formFieldPrice";
|
2017-07-27 16:48:18 +02:00
|
|
|
|
|
|
|
class TipLink extends React.PureComponent {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
feeAmount: "1.00",
|
2017-07-28 01:34:42 +02:00
|
|
|
currency: "LBC",
|
2017-07-27 16:48:18 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-08-08 00:13:58 +02:00
|
|
|
handleSupportButtonClicked() {
|
2017-07-29 08:50:17 +02:00
|
|
|
this.resetDefaults();
|
2017-07-28 01:34:42 +02:00
|
|
|
this.props.onTipShow();
|
2017-07-27 16:48:18 +02:00
|
|
|
}
|
|
|
|
|
2017-08-08 00:13:58 +02:00
|
|
|
handleSendButtonClicked() {
|
|
|
|
let claim_id = this.props.claim_id;
|
2017-07-27 16:48:18 +02:00
|
|
|
let amount = this.state.feeAmount;
|
|
|
|
|
2017-08-14 11:43:40 +02:00
|
|
|
this.props.sendSupport(amount, claim_id);
|
2017-07-27 16:48:18 +02:00
|
|
|
|
2017-07-28 01:34:42 +02:00
|
|
|
this.props.onTipHide();
|
2017-07-27 16:48:18 +02:00
|
|
|
}
|
|
|
|
|
2017-08-08 00:13:58 +02:00
|
|
|
handleSupportCancelButtonClicked() {
|
2017-07-28 01:34:42 +02:00
|
|
|
this.props.onTipHide();
|
2017-07-27 16:48:18 +02:00
|
|
|
}
|
|
|
|
|
2017-08-08 00:13:58 +02:00
|
|
|
handleSupportPriceChange(newValue) {
|
2017-07-27 16:48:18 +02:00
|
|
|
this.setState({
|
2017-08-08 00:13:58 +02:00
|
|
|
feeAmount: newValue.amount,
|
|
|
|
feeCurrency: newValue.currency,
|
2017-07-28 01:34:42 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-07-29 08:50:17 +02:00
|
|
|
resetDefaults() {
|
|
|
|
this.setState({
|
|
|
|
feeAmount: "1.00",
|
|
|
|
currency: "LBC",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-07-27 16:48:18 +02:00
|
|
|
render() {
|
2017-07-28 01:34:42 +02:00
|
|
|
const { showTipBox } = this.props;
|
2017-08-08 00:13:58 +02:00
|
|
|
const { feeAmount, currency } = this.state;
|
2017-07-27 16:48:18 +02:00
|
|
|
|
|
|
|
let tipLink = (
|
|
|
|
<Link
|
2017-08-08 00:13:58 +02:00
|
|
|
label={__("Support")}
|
2017-07-27 16:48:18 +02:00
|
|
|
button="text"
|
|
|
|
icon="icon-gift"
|
2017-08-08 00:13:58 +02:00
|
|
|
onClick={this.handleSupportButtonClicked.bind(this)}
|
2017-07-27 16:48:18 +02:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
let tipBox = (
|
|
|
|
<span>
|
2017-08-08 00:13:58 +02:00
|
|
|
<FormFieldPrice
|
|
|
|
min="0"
|
2017-07-28 01:34:42 +02:00
|
|
|
placeholder="1.00"
|
|
|
|
step="0.1"
|
2017-08-08 00:13:58 +02:00
|
|
|
onChange={value => this.handleSupportPriceChange(value)}
|
|
|
|
defaultValue={{ amount: feeAmount, currency: currency }}
|
2017-07-27 16:48:18 +02:00
|
|
|
/>
|
|
|
|
<Link
|
2017-08-08 00:13:58 +02:00
|
|
|
label={__("Send")}
|
2017-07-27 16:48:18 +02:00
|
|
|
button="primary"
|
2017-08-08 00:13:58 +02:00
|
|
|
onClick={this.handleSendButtonClicked.bind(this)}
|
2017-07-27 16:48:18 +02:00
|
|
|
/>
|
|
|
|
<Link
|
|
|
|
label={__("Cancel")}
|
|
|
|
button="alt"
|
2017-08-08 00:13:58 +02:00
|
|
|
onClick={this.handleSupportCancelButtonClicked.bind(this)}
|
2017-07-27 16:48:18 +02:00
|
|
|
/>
|
2017-07-29 10:36:42 +02:00
|
|
|
<div className="form-field__helper">
|
|
|
|
{__("This sends the entered amount of LBCs to the publisher.")}
|
|
|
|
</div>
|
2017-07-27 16:48:18 +02:00
|
|
|
</span>
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
2017-07-27 18:55:51 +02:00
|
|
|
<div className="menu-container">
|
2017-07-27 16:48:18 +02:00
|
|
|
{showTipBox ? tipBox : tipLink}
|
2017-07-27 18:55:51 +02:00
|
|
|
</div>
|
2017-07-27 16:48:18 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default TipLink;
|