2017-07-27 16:48:18 +02:00
|
|
|
import React from "react";
|
|
|
|
import Link from "component/link";
|
|
|
|
import { FormField } from "component/form";
|
2017-07-28 01:34:42 +02:00
|
|
|
import PriceForm from "component/priceForm";
|
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
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
handleTipPublisherButtonClicked() {
|
2017-07-28 01:34:42 +02:00
|
|
|
this.props.onTipShow();
|
2017-07-27 16:48:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
handleTipButtonClicked() {
|
|
|
|
let address = this.props.claim.address;
|
|
|
|
let amount = this.state.feeAmount;
|
|
|
|
|
|
|
|
this.props.setAddress(address);
|
|
|
|
this.props.setAmount(amount);
|
|
|
|
this.props.sendToAddress();
|
|
|
|
|
2017-07-28 01:34:42 +02:00
|
|
|
this.props.onTipHide();
|
2017-07-27 16:48:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
handleTipCancelButtonClicked() {
|
2017-07-28 01:34:42 +02:00
|
|
|
this.props.onTipHide();
|
2017-07-27 16:48:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
handleFeeAmountChange(event) {
|
|
|
|
this.setState({
|
|
|
|
feeAmount: event.target.value,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-07-28 01:34:42 +02:00
|
|
|
handleCurrencyChange(event) {
|
|
|
|
this.setState({
|
|
|
|
currency: event.target.value,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-07-27 16:48:18 +02:00
|
|
|
render() {
|
2017-07-28 01:34:42 +02:00
|
|
|
const { showTipBox } = this.props;
|
2017-07-27 16:48:18 +02:00
|
|
|
|
|
|
|
let tipLink = (
|
|
|
|
<Link
|
2017-07-28 01:34:42 +02:00
|
|
|
label={__("Tip")}
|
2017-07-27 16:48:18 +02:00
|
|
|
button="text"
|
|
|
|
icon="icon-gift"
|
|
|
|
onClick={this.handleTipPublisherButtonClicked.bind(this)}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
let tipBox = (
|
|
|
|
<span>
|
2017-07-28 01:34:42 +02:00
|
|
|
<PriceForm
|
2017-07-27 16:48:18 +02:00
|
|
|
min="0.01"
|
2017-07-28 01:34:42 +02:00
|
|
|
placeholder="1.00"
|
|
|
|
step="0.1"
|
|
|
|
onFeeChange={event => this.handleFeeAmountChange(event)}
|
|
|
|
defaultFeeValue="1.00"
|
|
|
|
onCurrencyChange={event => this.handleCurrencyChange(event)}
|
|
|
|
defaultCurrencyValue="LBC"
|
2017-07-27 16:48:18 +02:00
|
|
|
/>
|
|
|
|
{__(" ")}
|
|
|
|
<Link
|
|
|
|
label={__("Tip")}
|
|
|
|
button="primary"
|
|
|
|
onClick={this.handleTipButtonClicked.bind(this)}
|
|
|
|
/>
|
|
|
|
<Link
|
|
|
|
label={__("Cancel")}
|
|
|
|
button="alt"
|
|
|
|
onClick={this.handleTipCancelButtonClicked.bind(this)}
|
|
|
|
/>
|
|
|
|
</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;
|