diff --git a/package-lock.json b/package-lock.json index aabd8ce9..4b72fd3c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "bfj": "^7.0.2", "bootstrap": "^4.6.0", "camelcase": "^6.1.0", + "date-fns": "^3.6.0", "form-data": "^4.0.0", "fs-extra": "^9.0.1", "identity-obj-proxy": "3.0.0", @@ -9385,15 +9386,12 @@ } }, "node_modules/date-fns": { - "version": "2.29.3", - "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz", - "integrity": "sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==", - "engines": { - "node": ">=0.11" - }, + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-3.6.0.tgz", + "integrity": "sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==", "funding": { - "type": "opencollective", - "url": "https://opencollective.com/date-fns" + "type": "github", + "url": "https://github.com/sponsors/kossnocorp" } }, "node_modules/debug": { @@ -20791,6 +20789,21 @@ "react-dom": "^16.9.0 || ^17 || ^18" } }, + "node_modules/react-datepicker/node_modules/date-fns": { + "version": "2.30.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", + "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==", + "dependencies": { + "@babel/runtime": "^7.21.0" + }, + "engines": { + "node": ">=0.11" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/date-fns" + } + }, "node_modules/react-dev-utils": { "version": "12.0.1", "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.1.tgz", diff --git a/package.json b/package.json index d35d2845..93d109f5 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "bfj": "^7.0.2", "bootstrap": "^4.6.0", "camelcase": "^6.1.0", + "date-fns": "^3.6.0", "form-data": "^4.0.0", "fs-extra": "^9.0.1", "identity-obj-proxy": "3.0.0", diff --git a/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx b/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx index 19361a8c..d0a6bed4 100644 --- a/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx +++ b/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx @@ -5,7 +5,6 @@ import React, { useEffect, useState } from "react"; import DatePicker, { registerLocale } from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css"; import { useDispatch, useSelector } from "react-redux"; -import { Link, useLocation } from "react-router-dom"; import { getProfileInfo } from "@redux/outstaffingSlice"; import { setProjectBoardFetch } from "@redux/projectsTrackerSlice"; @@ -60,7 +59,6 @@ export const ModalTiсket = ({ projectMarks }) => { const dispatch = useDispatch(); - const location = useLocation(); const [addSubtask, setAddSubtask] = useState(false); const [editOpen, setEditOpen] = useState(false); @@ -91,10 +89,18 @@ export const ModalTiсket = ({ seconds: 0 }); const additionalData = { - id: task.id, - title: inputsValue.title, - link: null, - nameProject: projectName + difficulties: "", + project_id: task.project_id, + status: task.status, + tasks: [ + { + hours_spent: currentTimerCount.hours, + minutes_spent: currentTimerCount.minute, + task: task.title + } + ], + tomorrow: "", + user_id: task.executor_id }; const [timerId, setTimerId] = useState(null); const [taskFiles, setTaskFiles] = useState([]); @@ -124,6 +130,7 @@ export const ModalTiсket = ({ window.history.replaceState({}, "", newUrl); // Восстанавливаем скролл при закрытии модального окна document.body.style.overflow = "auto"; + console.log(task); }; const [isExpanded, setIsExpanded] = useState(false); diff --git a/src/components/Modal/Tracker/ModalTicketToReport/ModalTicketToReport.jsx b/src/components/Modal/Tracker/ModalTicketToReport/ModalTicketToReport.jsx index 0f1f282b..76d3966a 100644 --- a/src/components/Modal/Tracker/ModalTicketToReport/ModalTicketToReport.jsx +++ b/src/components/Modal/Tracker/ModalTicketToReport/ModalTicketToReport.jsx @@ -1,4 +1,5 @@ import axios from "axios"; +import { format } from "date-fns"; import React, { useState } from "react"; import DatePicker from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css"; @@ -13,19 +14,18 @@ const ModalTicketToReport = ({ show, onClose, additionalData }) => { const [date, setDate] = useState(new Date()); const handleSubmit = async () => { + const formattedDate = format(date, "yyyy-MM-dd"); const data = { - date, + created_at: formattedDate, ...additionalData }; + console.log(data); try { - await apiRequest( - "https://back.itguild.info/profile/calendar/reports/create", - { - method: "POST", - data: data - } - ); + await apiRequest("https://back.itguild.info/api/reports/create", { + method: "POST", + data: data + }); } catch (error) { console.error("Error:", error); }