fix uploading to the report

This commit is contained in:
Никита Губарь 2024-07-04 22:59:20 +03:00
parent d45e600c93
commit 4c7e21b430
4 changed files with 43 additions and 22 deletions

29
package-lock.json generated
View File

@ -20,6 +20,7 @@
"bfj": "^7.0.2", "bfj": "^7.0.2",
"bootstrap": "^4.6.0", "bootstrap": "^4.6.0",
"camelcase": "^6.1.0", "camelcase": "^6.1.0",
"date-fns": "^3.6.0",
"form-data": "^4.0.0", "form-data": "^4.0.0",
"fs-extra": "^9.0.1", "fs-extra": "^9.0.1",
"identity-obj-proxy": "3.0.0", "identity-obj-proxy": "3.0.0",
@ -9385,15 +9386,12 @@
} }
}, },
"node_modules/date-fns": { "node_modules/date-fns": {
"version": "2.29.3", "version": "3.6.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.29.3.tgz", "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-3.6.0.tgz",
"integrity": "sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==", "integrity": "sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==",
"engines": {
"node": ">=0.11"
},
"funding": { "funding": {
"type": "opencollective", "type": "github",
"url": "https://opencollective.com/date-fns" "url": "https://github.com/sponsors/kossnocorp"
} }
}, },
"node_modules/debug": { "node_modules/debug": {
@ -20791,6 +20789,21 @@
"react-dom": "^16.9.0 || ^17 || ^18" "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": { "node_modules/react-dev-utils": {
"version": "12.0.1", "version": "12.0.1",
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.1.tgz", "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.1.tgz",

View File

@ -16,6 +16,7 @@
"bfj": "^7.0.2", "bfj": "^7.0.2",
"bootstrap": "^4.6.0", "bootstrap": "^4.6.0",
"camelcase": "^6.1.0", "camelcase": "^6.1.0",
"date-fns": "^3.6.0",
"form-data": "^4.0.0", "form-data": "^4.0.0",
"fs-extra": "^9.0.1", "fs-extra": "^9.0.1",
"identity-obj-proxy": "3.0.0", "identity-obj-proxy": "3.0.0",

View File

@ -5,7 +5,6 @@ import React, { useEffect, useState } from "react";
import DatePicker, { registerLocale } from "react-datepicker"; import DatePicker, { registerLocale } from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css"; import "react-datepicker/dist/react-datepicker.css";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { Link, useLocation } from "react-router-dom";
import { getProfileInfo } from "@redux/outstaffingSlice"; import { getProfileInfo } from "@redux/outstaffingSlice";
import { setProjectBoardFetch } from "@redux/projectsTrackerSlice"; import { setProjectBoardFetch } from "@redux/projectsTrackerSlice";
@ -60,7 +59,6 @@ export const ModalTiсket = ({
projectMarks projectMarks
}) => { }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const location = useLocation();
const [addSubtask, setAddSubtask] = useState(false); const [addSubtask, setAddSubtask] = useState(false);
const [editOpen, setEditOpen] = useState(false); const [editOpen, setEditOpen] = useState(false);
@ -91,10 +89,18 @@ export const ModalTiсket = ({
seconds: 0 seconds: 0
}); });
const additionalData = { const additionalData = {
id: task.id, difficulties: "",
title: inputsValue.title, project_id: task.project_id,
link: null, status: task.status,
nameProject: projectName tasks: [
{
hours_spent: currentTimerCount.hours,
minutes_spent: currentTimerCount.minute,
task: task.title
}
],
tomorrow: "",
user_id: task.executor_id
}; };
const [timerId, setTimerId] = useState(null); const [timerId, setTimerId] = useState(null);
const [taskFiles, setTaskFiles] = useState([]); const [taskFiles, setTaskFiles] = useState([]);
@ -124,6 +130,7 @@ export const ModalTiсket = ({
window.history.replaceState({}, "", newUrl); window.history.replaceState({}, "", newUrl);
// Восстанавливаем скролл при закрытии модального окна // Восстанавливаем скролл при закрытии модального окна
document.body.style.overflow = "auto"; document.body.style.overflow = "auto";
console.log(task);
}; };
const [isExpanded, setIsExpanded] = useState(false); const [isExpanded, setIsExpanded] = useState(false);

View File

@ -1,4 +1,5 @@
import axios from "axios"; import axios from "axios";
import { format } from "date-fns";
import React, { useState } from "react"; import React, { 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";
@ -13,19 +14,18 @@ const ModalTicketToReport = ({ show, onClose, additionalData }) => {
const [date, setDate] = useState(new Date()); const [date, setDate] = useState(new Date());
const handleSubmit = async () => { const handleSubmit = async () => {
const formattedDate = format(date, "yyyy-MM-dd");
const data = { const data = {
date, created_at: formattedDate,
...additionalData ...additionalData
}; };
console.log(data);
try { try {
await apiRequest( await apiRequest("https://back.itguild.info/api/reports/create", {
"https://back.itguild.info/profile/calendar/reports/create",
{
method: "POST", method: "POST",
data: data data: data
} });
);
} catch (error) { } catch (error) {
console.error("Error:", error); console.error("Error:", error);
} }