This commit is contained in:
Николай Полтщук 2023-07-13 02:03:53 +03:00
parent 4f613f492e
commit f8d7abdeba

View File

@ -10,7 +10,12 @@ import { Link } from "react-router-dom";
import { getProfileInfo } from "@redux/outstaffingSlice"; import { getProfileInfo } from "@redux/outstaffingSlice";
import { setProjectBoardFetch } from "@redux/projectsTrackerSlice"; import { setProjectBoardFetch } from "@redux/projectsTrackerSlice";
import {caseOfNum, getCorrectRequestDate, getToken, urlForLocal} from "@utils/helper"; import {
caseOfNum,
getCorrectRequestDate,
getToken,
urlForLocal,
} from "@utils/helper";
import { apiRequest } from "@api/request"; import { apiRequest } from "@api/request";
@ -63,7 +68,7 @@ export const ModalTiсket = ({
const [executor, setExecutor] = useState(task.executor); const [executor, setExecutor] = useState(task.executor);
const [members, setMembers] = useState(task.taskUsers); const [members, setMembers] = useState(task.taskUsers);
const [users, setUsers] = useState([]); const [users, setUsers] = useState([]);
const [selectedFile, setSelectedFile] = useState(null) const [selectedFile, setSelectedFile] = useState(null);
const [timerStart, setTimerStart] = useState(false); const [timerStart, setTimerStart] = useState(false);
const [timerInfo, setTimerInfo] = useState({}); const [timerInfo, setTimerInfo] = useState({});
const [currentTimerCount, setCurrentTimerCount] = useState({ const [currentTimerCount, setCurrentTimerCount] = useState({
@ -304,9 +309,8 @@ export const ModalTiсket = ({
}, []); }, []);
const handleUpload = async (event) => { const handleUpload = async (event) => {
const formData = new FormData();
const formData = new FormData() formData.append("uploadFile ", event.target.files[0]);
formData.append('uploadFile ', event.target.files[0])
// apiRequest('/file/upload', { // apiRequest('/file/upload', {
// method: 'POST', // method: 'POST',
// data: { // data: {
@ -316,18 +320,18 @@ export const ModalTiсket = ({
// console.log(res) // console.log(res)
// }) // })
// console.log(formData) // console.log(formData)
const res = await fetch('https://itguild.info/file/upload', { const res = await fetch("https://itguild.info/file/upload", {
method: 'POST', method: "POST",
body: formData, body: formData,
headers: { headers: {
"Access-Control-Allow-Origin": "*", "Access-Control-Allow-Origin": "*",
"Content-Type": "application/json", "Content-Type": "application/json",
...getToken() ...getToken(),
} },
}) });
console.log(res) console.log(res);
} };
function startTimer() { function startTimer() {
setTimerId( setTimerId(
@ -475,19 +479,16 @@ export const ModalTiсket = ({
{/* </button>*/} {/* </button>*/}
{/*</p>*/} {/*</p>*/}
<div className="file"> <div className="file">
<div className='input__wrapper'> <div className="input__wrapper">
<input <input
name="file" name="file"
id="input__file" id="input__file"
type="file" type="file"
accept="image/*,.png,.jpg,.svg,.jpeg" accept="image/*,.png,.jpg,.svg,.jpeg"
className='input__file' className="input__file"
onChange={handleUpload} onChange={handleUpload}
/> />
<label <label htmlFor="input__file" className="button-add-file">
htmlFor="input__file"
className="button-add-file"
>
<img src={file}></img> <img src={file}></img>
Загрузить файл Загрузить файл
</label> </label>