diff --git a/src/components/Modal/Tracker/ModalTicketToReport/ModalTicketToReport.jsx b/src/components/Modal/Tracker/ModalTicketToReport/ModalTicketToReport.jsx index c9a2d69a..3991a818 100644 --- a/src/components/Modal/Tracker/ModalTicketToReport/ModalTicketToReport.jsx +++ b/src/components/Modal/Tracker/ModalTicketToReport/ModalTicketToReport.jsx @@ -2,7 +2,6 @@ import { format } from "date-fns"; import React, { useEffect, useState } from "react"; import DatePicker from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css"; -import { useNavigate } from "react-router"; import { apiRequest } from "@api/request"; @@ -14,10 +13,9 @@ import "./modalTicketToReport.scss"; const ModalTicketToReport = ({ show, onClose, additionalData }) => { const [date, setDate] = useState(new Date()); - const [inputValue, setInputValue] = useState(0); + const [inputValue, setInputValue] = useState(1); const [taskDescription, setTaskDescription] = useState(""); - const navigate = useNavigate(); const { showNotification } = useNotification(); useEffect(() => { @@ -33,7 +31,9 @@ const ModalTicketToReport = ({ show, onClose, additionalData }) => { useEffect(() => { const hoursSpent = additionalData.task.hours_spent; - setInputValue(hoursSpent); + if (hoursSpent !== 0) { + setInputValue(hoursSpent); + } }, [additionalData.task.hours_spent]); const handleSubmit = async () => { @@ -64,9 +64,15 @@ const ModalTicketToReport = ({ show, onClose, additionalData }) => { text: "Отчет успешно создан", type: "true" }); + return true; }) - .catch((error) => { - console.error("Error:", error); + .catch(() => { + showNotification({ + show: true, + text: "Error", + type: "error" + }); + return false; }); }) .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 value = Number(e.target.value); if (value !== 0) { @@ -101,25 +98,27 @@ const ModalTicketToReport = ({ show, onClose, additionalData }) => { >