funct
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { HttpApiMethods } from '../utils/FetchUtils';
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
|
||||
const PostForm = () => {
|
||||
@ -7,10 +8,11 @@ const PostForm = () => {
|
||||
const [dataIsLoad, setDataIsLoad] = useState(false)
|
||||
|
||||
let post = async () => {
|
||||
const token = Cookies.get('token')
|
||||
const httpApiMethods = new HttpApiMethods();
|
||||
let formData = new FormData(formRef.current); // Изменение этой строки
|
||||
setDataIsLoad(false)
|
||||
const updatedMeets = httpApiMethods.AddMeetings(formData)
|
||||
const updatedMeets = httpApiMethods.AddMeetings(formData, token)
|
||||
.then(
|
||||
() => {
|
||||
setDataIsLoad(true)
|
||||
@ -22,7 +24,7 @@ const PostForm = () => {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>Post</h2>
|
||||
<h2>Создать мероприятие</h2>
|
||||
<div>{dataIsLoad ? "ДАнные успешно загрузилисб" : ""}</div>
|
||||
<form ref={formRef} action=''>
|
||||
<input type="text" placeholder='title' name='title'/>
|
||||
|
@ -21,7 +21,7 @@ const Users = () => {
|
||||
const httpApiMethods = new HttpApiMethods();
|
||||
let formData = new FormData(formRef.current);
|
||||
|
||||
if (!formData.get('fio') || !formData.get('avatar') || !formData.get('username') || !formData.get('specialities') || !formData.get('telegramBotUrl')) {
|
||||
if (!formData.get('fio') || !formData.get('avatar') || !formData.get('username') || !formData.get('specialities') || !formData.get('email') || !formData.get('telegramBotUrl')) {
|
||||
console.error('Ошибка: Не все поля формы заполнены');
|
||||
return;
|
||||
}
|
||||
@ -47,6 +47,7 @@ const Users = () => {
|
||||
<input type="text" placeholder='fio' name='fio' />
|
||||
<input type="file" placeholder='avatar' name='avatar' />
|
||||
<input type="text" placeholder='username' name='username' />
|
||||
<input type="email" placeholder='email' name='email' />
|
||||
<input type="text" placeholder='specialities' name='specialities' />
|
||||
<input type="text" placeholder='telegramBotUrl' name='telegramBotUrl' />
|
||||
<button onClick={post}>Create</button>
|
||||
|
Reference in New Issue
Block a user