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",
"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",

View File

@ -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",

View File

@ -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);

View File

@ -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",
{
await apiRequest("https://back.itguild.info/api/reports/create", {
method: "POST",
data: data
}
);
});
} catch (error) {
console.error("Error:", error);
}