fix ModalTicketToReport
This commit is contained in:
parent
c839f2f92e
commit
93ed3adfee
@ -2,7 +2,6 @@ import { format } from "date-fns";
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } 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";
|
||||||
import { useNavigate } from "react-router";
|
|
||||||
|
|
||||||
import { apiRequest } from "@api/request";
|
import { apiRequest } from "@api/request";
|
||||||
|
|
||||||
@ -14,10 +13,9 @@ import "./modalTicketToReport.scss";
|
|||||||
|
|
||||||
const ModalTicketToReport = ({ show, onClose, additionalData }) => {
|
const ModalTicketToReport = ({ show, onClose, additionalData }) => {
|
||||||
const [date, setDate] = useState(new Date());
|
const [date, setDate] = useState(new Date());
|
||||||
const [inputValue, setInputValue] = useState(0);
|
const [inputValue, setInputValue] = useState(1);
|
||||||
const [taskDescription, setTaskDescription] = useState("");
|
const [taskDescription, setTaskDescription] = useState("");
|
||||||
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const { showNotification } = useNotification();
|
const { showNotification } = useNotification();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -33,7 +31,9 @@ const ModalTicketToReport = ({ show, onClose, additionalData }) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const hoursSpent = additionalData.task.hours_spent;
|
const hoursSpent = additionalData.task.hours_spent;
|
||||||
setInputValue(hoursSpent);
|
if (hoursSpent !== 0) {
|
||||||
|
setInputValue(hoursSpent);
|
||||||
|
}
|
||||||
}, [additionalData.task.hours_spent]);
|
}, [additionalData.task.hours_spent]);
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
@ -64,9 +64,15 @@ const ModalTicketToReport = ({ show, onClose, additionalData }) => {
|
|||||||
text: "Отчет успешно создан",
|
text: "Отчет успешно создан",
|
||||||
type: "true"
|
type: "true"
|
||||||
});
|
});
|
||||||
|
return true;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(() => {
|
||||||
console.error("Error:", error);
|
showNotification({
|
||||||
|
show: true,
|
||||||
|
text: "Error",
|
||||||
|
type: "error"
|
||||||
|
});
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
@ -74,15 +80,6 @@ const ModalTicketToReport = ({ show, onClose, additionalData }) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const toTheReport = async () => {
|
|
||||||
const success = await handleSubmit();
|
|
||||||
if (success) {
|
|
||||||
navigate(
|
|
||||||
`/profile/calendar/view/${additionalData.created_at}/${additionalData.user_id}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleInputChange = (e) => {
|
const handleInputChange = (e) => {
|
||||||
const value = Number(e.target.value);
|
const value = Number(e.target.value);
|
||||||
if (value !== 0) {
|
if (value !== 0) {
|
||||||
@ -101,25 +98,27 @@ const ModalTicketToReport = ({ show, onClose, additionalData }) => {
|
|||||||
>
|
>
|
||||||
<div className="modal-report-close" onClick={onClose}></div>
|
<div className="modal-report-close" onClick={onClose}></div>
|
||||||
<h2>Выгрузка в отчет</h2>
|
<h2>Выгрузка в отчет</h2>
|
||||||
<div className="modal-report-date-picker">
|
<div className="modal-report-form">
|
||||||
<label htmlFor="date-picker">Дата отчета:</label>
|
<div className="modal-report-date-picker">
|
||||||
<DatePicker
|
<label htmlFor="date-picker">Дата отчета:</label>
|
||||||
id="date-picker"
|
<DatePicker
|
||||||
className="datePicker"
|
id="date-picker"
|
||||||
locale="ru"
|
className="datePicker"
|
||||||
selected={date}
|
locale="ru"
|
||||||
onChange={(date) => setDate(date)}
|
selected={date}
|
||||||
dateFormat="dd/MM/yyyy"
|
onChange={(date) => setDate(date)}
|
||||||
/>
|
dateFormat="dd/MM/yyyy"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<label className="modal-report-input-time">
|
||||||
|
Время выполнения:
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={inputValue}
|
||||||
|
onChange={handleInputChange}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<label className="modal-report-input-time">
|
|
||||||
Время выполнения:
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
value={inputValue}
|
|
||||||
onChange={handleInputChange}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<div className="modal-report__buttons">
|
<div className="modal-report__buttons">
|
||||||
<BaseButton
|
<BaseButton
|
||||||
@ -128,12 +127,6 @@ const ModalTicketToReport = ({ show, onClose, additionalData }) => {
|
|||||||
>
|
>
|
||||||
Выгрузить в отчет
|
Выгрузить в отчет
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
<BaseButton
|
|
||||||
styles={`button-add add-person-btn ${show ? "" : "disable"}`}
|
|
||||||
onClick={toTheReport}
|
|
||||||
>
|
|
||||||
Выгрузить и перейти в отчет
|
|
||||||
</BaseButton>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -22,12 +22,15 @@
|
|||||||
padding: 20px;
|
padding: 20px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
position: relative;
|
position: relative;
|
||||||
max-width: 600px;
|
width: 450px;
|
||||||
height: 500px;
|
height: 300px;
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
|
@media (max-width: 880px) {
|
||||||
|
width: 300px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&-close {
|
&-close {
|
||||||
@ -59,17 +62,24 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&-date-picker {
|
&-form {
|
||||||
// .datePicker {
|
display: flex;
|
||||||
// visibility: hidden;
|
align-items: center;
|
||||||
// height: 0;
|
justify-content: center;
|
||||||
// padding: 0;
|
column-gap: 40px;
|
||||||
// width: 0;
|
|
||||||
// position: absolute;
|
|
||||||
// }
|
|
||||||
|
|
||||||
.react-datepicker-wrapper {
|
@media (max-width: 880px) {
|
||||||
// position: absolute;
|
flex-direction: column;
|
||||||
|
row-gap: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-date-picker {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
label {
|
||||||
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.react-datepicker {
|
.react-datepicker {
|
||||||
@ -78,14 +88,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.react-datepicker-popper {
|
.react-datepicker-popper {
|
||||||
top: -90px !important;
|
|
||||||
left: 250px !important;
|
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
|
|
||||||
@media (max-width: 880px) {
|
|
||||||
left: 0 !important;
|
|
||||||
top: -15px !important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.react-datepicker__current-month {
|
.react-datepicker__current-month {
|
||||||
@ -155,7 +158,7 @@
|
|||||||
&-input-time {
|
&-input-time {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: 30%;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__buttons {
|
&__buttons {
|
||||||
|
Loading…
Reference in New Issue
Block a user