._.
This commit is contained in:
parent
7e2799e1ac
commit
0b7743bb77
@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import DatePicker from "react-datepicker";
|
import DatePicker from "react-datepicker";
|
||||||
import "react-datepicker/dist/react-datepicker.css";
|
import "react-datepicker/dist/react-datepicker.css";
|
||||||
|
|
||||||
@ -7,12 +7,22 @@ const AddOrderModal = ({ show, onHide, onSubmit }) => {
|
|||||||
const [robotsCount, setRobotsCount] = useState(100);
|
const [robotsCount, setRobotsCount] = useState(100);
|
||||||
const [formError, setFormError] = useState("");
|
const [formError, setFormError] = useState("");
|
||||||
|
|
||||||
const minDate = new Date();
|
const getMinDate = () => {
|
||||||
minDate.setMonth(minDate.getMonth() + 1);
|
const minDate = new Date();
|
||||||
|
minDate.setMonth(minDate.getMonth() + 1);
|
||||||
|
|
||||||
if (minDate.getMonth() === 0) {
|
if (minDate.getMonth() === 0) {
|
||||||
minDate.setFullYear(minDate.getFullYear() + 1);
|
minDate.setFullYear(minDate.getFullYear() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return minDate;
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (show) {
|
||||||
|
setDeadline(getMinDate());
|
||||||
|
}
|
||||||
|
}, [show]);
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
if (!deadline || robotsCount < 100 || robotsCount % 100 !== 0) {
|
if (!deadline || robotsCount < 100 || robotsCount % 100 !== 0) {
|
||||||
@ -85,7 +95,7 @@ const AddOrderModal = ({ show, onHide, onSubmit }) => {
|
|||||||
className="form-control"
|
className="form-control"
|
||||||
dateFormat="P"
|
dateFormat="P"
|
||||||
placeholderText="Выберите дату дедлайна"
|
placeholderText="Выберите дату дедлайна"
|
||||||
minDate={minDate}
|
minDate={getMinDate()}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user