contract change options 'number_paydate' datefield fix for wrong values
This commit is contained in:
parent
fbd8c16616
commit
dbd8ea72f5
@ -90,6 +90,7 @@ export default class DateInput extends React.Component
|
|||||||
min={ min }
|
min={ min }
|
||||||
max={ max }
|
max={ max }
|
||||||
onChange={ this._handle_onChange }
|
onChange={ this._handle_onChange }
|
||||||
|
className={ this.props.className }
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -18,6 +18,7 @@ class PaymentDate extends React.Component
|
|||||||
min: null,
|
min: null,
|
||||||
max: null,
|
max: null,
|
||||||
help: false,
|
help: false,
|
||||||
|
error: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,12 +39,25 @@ class PaymentDate extends React.Component
|
|||||||
_handle_onChange = (value) =>
|
_handle_onChange = (value) =>
|
||||||
{
|
{
|
||||||
const { onOption } = this.props;
|
const { onOption } = this.props;
|
||||||
|
const { min, max } = this.state;
|
||||||
|
|
||||||
this.setState({ value }, () =>
|
const v = moment(value).toDate();
|
||||||
|
|
||||||
|
if(v >= min && v <= max )
|
||||||
|
{
|
||||||
|
this.setState({ value, error: false, }, () =>
|
||||||
{
|
{
|
||||||
onOption(value);
|
onOption(value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setState({ value: undefined, error: true }, () =>
|
||||||
|
{
|
||||||
|
onOption(v, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_handle_onMobileHelp = () =>
|
_handle_onMobileHelp = () =>
|
||||||
{
|
{
|
||||||
@ -56,11 +70,12 @@ class PaymentDate extends React.Component
|
|||||||
render()
|
render()
|
||||||
{
|
{
|
||||||
const { option } = this.props;
|
const { option } = this.props;
|
||||||
const { value, min, max } = this.state;
|
const { value, min, max, error } = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="form_field">
|
<div className="form_field" style={error ? { marginBottom: "30px" } : {}}>
|
||||||
<label>Дата платежа:</label>
|
<label>Дата платежа:</label>
|
||||||
|
<div style={{ position: "relative", }}>
|
||||||
<DateInput
|
<DateInput
|
||||||
placeholder=""
|
placeholder=""
|
||||||
value={ value }
|
value={ value }
|
||||||
@ -68,9 +83,15 @@ class PaymentDate extends React.Component
|
|||||||
max={ max }
|
max={ max }
|
||||||
id={"date_to"}
|
id={"date_to"}
|
||||||
onChange={ this._handle_onChange }
|
onChange={ this._handle_onChange }
|
||||||
|
onClick={ () => this.setState({ error: false }) }
|
||||||
disabled={ option.disable ? true : false }
|
disabled={ option.disable ? true : false }
|
||||||
plain={ true }
|
plain={ true }
|
||||||
|
className={ error ? "error" : "" }
|
||||||
/>
|
/>
|
||||||
|
{ error && (
|
||||||
|
<p style={{ position: "absolute", left: "20px", lineHeight: "16px", color: "red", fontSsize: "12px", top: "45px" }}>Выберите дату между { min !== null && moment(min).format("DD.MM.YYYY") } и { max !== null && moment(max).format("DD.MM.YYYY") }</p>
|
||||||
|
) }
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -690,9 +711,12 @@ export default class Options extends React.Component
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_handle_onPaymentDateChange = (date) =>
|
_handle_onPaymentDateChange = (date, error) =>
|
||||||
{
|
{
|
||||||
this.setState({ number_paydate: date });
|
const { errors } = this.state;
|
||||||
|
|
||||||
|
if(error) { errors['paydate'] = true; } else { delete errors['paydate']; }
|
||||||
|
this.setState({ number_paydate: date, errors });
|
||||||
}
|
}
|
||||||
|
|
||||||
_handle_onFixLastPaymentChange = (value) =>
|
_handle_onFixLastPaymentChange = (value) =>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user