2017-08-04 05:31:53 +02:00
|
|
|
import React from "react";
|
2017-08-07 00:24:55 +02:00
|
|
|
import FormField from "component/formField";
|
2017-08-04 05:31:53 +02:00
|
|
|
|
|
|
|
class FormFieldPrice extends React.PureComponent {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
price: {
|
|
|
|
feeAmount: "",
|
|
|
|
feeCurrency: "LBC",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
handleFeeAmountChange(event) {
|
|
|
|
this.setState({
|
|
|
|
price: {
|
|
|
|
...this.state.price,
|
|
|
|
feeAmount: event.target.value,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
this.props.onChange(event.target.name, this.state.price);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleFeeCurrencyChange(event) {
|
|
|
|
this.setState({
|
|
|
|
price: {
|
|
|
|
...this.state.price,
|
|
|
|
feeCurrency: event.target.value,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
this.props.onChange(event.target.name, this.state.price);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
2017-08-07 00:24:55 +02:00
|
|
|
defaultAmount,
|
|
|
|
defaultCurrency,
|
2017-08-04 05:31:53 +02:00
|
|
|
placeholder,
|
|
|
|
min,
|
|
|
|
step,
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<span className={"form-field "}>
|
|
|
|
<FormField
|
|
|
|
type="number"
|
|
|
|
name="amount"
|
|
|
|
min={min}
|
|
|
|
placeholder={placeholder || null}
|
|
|
|
step={step}
|
|
|
|
onChange={event => this.handleFeeAmountChange(event)}
|
2017-08-07 00:24:55 +02:00
|
|
|
defaultValue={defaultAmount}
|
2017-08-04 05:31:53 +02:00
|
|
|
className="form-field__input--inline"
|
|
|
|
/>
|
|
|
|
<FormField
|
|
|
|
type="select"
|
|
|
|
name="currency"
|
|
|
|
onChange={event => this.handleFeeCurrencyChange(event)}
|
2017-08-07 00:24:55 +02:00
|
|
|
defaultValue={defaultCurrency}
|
2017-08-04 05:31:53 +02:00
|
|
|
className="form-field__input--inline"
|
|
|
|
>
|
|
|
|
<option value="LBC">{__("LBRY credits")}</option>
|
|
|
|
<option value="USD">{__("US Dollars")}</option>
|
|
|
|
</FormField>
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default FormFieldPrice;
|