file
This commit is contained in:
parent
f8d7abdeba
commit
68d5a7ebcc
@ -68,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('');
|
||||||
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({
|
||||||
@ -308,29 +308,31 @@ export const ModalTiсket = ({
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleUpload = async (event) => {
|
function handleChange (event) {
|
||||||
|
setSelectedFile(event.target.files[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleUpload () {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("uploadFile ", event.target.files[0]);
|
formData.append('uploadFile', selectedFile);
|
||||||
// apiRequest('/file/upload', {
|
const headers = {
|
||||||
// method: 'POST',
|
|
||||||
// data: {
|
|
||||||
// formData
|
|
||||||
// }
|
|
||||||
// }).then((res) => {
|
|
||||||
// console.log(res)
|
|
||||||
// })
|
|
||||||
// console.log(formData)
|
|
||||||
const res = await fetch("https://itguild.info/file/upload", {
|
|
||||||
method: "POST",
|
|
||||||
body: formData,
|
|
||||||
headers: {
|
|
||||||
"Access-Control-Allow-Origin": "*",
|
"Access-Control-Allow-Origin": "*",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
...getToken(),
|
}
|
||||||
},
|
const fullHeaders = { ...headers, ...getToken() };
|
||||||
|
const res = await fetch("https://itguild.info/api/file/upload", {
|
||||||
|
method: "POST",
|
||||||
|
body: formData,
|
||||||
|
headers: { ...fullHeaders }
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(res);
|
console.log(fullHeaders)
|
||||||
|
console.log(res)
|
||||||
|
// apiRequest('/file/upload', {
|
||||||
|
// method: 'POST',
|
||||||
|
// body: formData
|
||||||
|
// }).then((res) => {
|
||||||
|
// })
|
||||||
};
|
};
|
||||||
|
|
||||||
function startTimer() {
|
function startTimer() {
|
||||||
@ -486,13 +488,14 @@ export const ModalTiсket = ({
|
|||||||
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={handleChange}
|
||||||
/>
|
/>
|
||||||
<label htmlFor="input__file" className="button-add-file">
|
<label htmlFor="input__file" className="button-add-file">
|
||||||
<img src={file}></img>
|
<img src={file}></img>
|
||||||
Загрузить файл
|
Загрузить файл
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<p onClick={handleUpload}>Отправить</p>
|
||||||
<span>{0}</span>
|
<span>{0}</span>
|
||||||
{caseOfNum(0, "files")}
|
{caseOfNum(0, "files")}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user