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