diff --git a/components/DatePicker/index.js b/components/DatePicker/index.js index 8455a34..c099110 100644 --- a/components/DatePicker/index.js +++ b/components/DatePicker/index.js @@ -90,6 +90,7 @@ export default class DateInput extends React.Component min={ min } max={ max } onChange={ this._handle_onChange } + className={ this.props.className } /> ) diff --git a/pages/contract/change/components/Options/index.js b/pages/contract/change/components/Options/index.js index b9fefd5..e46b9ab 100644 --- a/pages/contract/change/components/Options/index.js +++ b/pages/contract/change/components/Options/index.js @@ -18,6 +18,7 @@ class PaymentDate extends React.Component min: null, max: null, help: false, + error: false, } } @@ -38,11 +39,24 @@ class PaymentDate extends React.Component _handle_onChange = (value) => { const { onOption } = this.props; + const { min, max } = this.state; - this.setState({ value }, () => + const v = moment(value).toDate(); + + if(v >= min && v <= max ) { - onOption(value); - }); + this.setState({ value, error: false, }, () => + { + onOption(value); + }); + } + else + { + this.setState({ value: undefined, error: true }, () => + { + onOption(v, true); + }); + } } _handle_onMobileHelp = () => @@ -52,25 +66,32 @@ class PaymentDate extends React.Component this.setState({ help: this.state.help ? false : true }); } } - + render() { const { option } = this.props; - const { value, min, max } = this.state; + const { value, min, max, error } = this.state; return ( -
Выберите дату между { min !== null && moment(min).format("DD.MM.YYYY") } и { max !== null && moment(max).format("DD.MM.YYYY") }
+ ) } +