adding the api
This commit is contained in:
13
src/components/post/PostReviews.jsx
Normal file
13
src/components/post/PostReviews.jsx
Normal file
@ -0,0 +1,13 @@
|
||||
import React from 'react';
|
||||
|
||||
const PostReviews = () => {
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default PostReviews;
|
51
src/components/post/Questions.jsx
Normal file
51
src/components/post/Questions.jsx
Normal file
@ -0,0 +1,51 @@
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { HttpApiMethods } from '../utils/FetchUtils';
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
const Questions = () => {
|
||||
const formRef = useRef(null);
|
||||
const [dataIsLoad, setDataIsLoad] = useState(false);
|
||||
const [curentUser, setCurentUser] = useState(null);
|
||||
|
||||
let post = async (event) => {
|
||||
event.preventDefault();
|
||||
const httpApiMethods = new HttpApiMethods();
|
||||
const user_id = Cookies.get('userData')
|
||||
let formData = new FormData(formRef.current);
|
||||
|
||||
|
||||
|
||||
if (!formData.get('fio') || !formData.get('avatar') || !formData.get('userId') || !formData.get('text') || !formData.get('meetingId')) {
|
||||
console.error('Ошибка: Не все поля формы заполнены');
|
||||
return;
|
||||
}
|
||||
|
||||
setDataIsLoad(false);
|
||||
httpApiMethods.PostQuestions(formData).then(response => {
|
||||
console.log(response)
|
||||
setDataIsLoad(true);
|
||||
meets_id = '9c69d5e7-74ec-4f92-af3a-fef7d30c55bb'
|
||||
// let user_id = response.data.id;
|
||||
// console.log(response)
|
||||
// console.log(user_id)
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>Создание Questions, получение ID в Cookies</h2>
|
||||
<div>{dataIsLoad ? "Данные успешно загружены" : ""}</div>
|
||||
<form ref={formRef} action=''>
|
||||
|
||||
{/* <input type="text" placeholder='userId' name={Cookies.get('userData')} /> */}
|
||||
<input type="text" placeholder='userId' name='userId' value={Cookies.get('userId')} />
|
||||
<input type="text" placeholder='text' name='text' />
|
||||
<input type="text" placeholder='meetingId' name='meetingId' value={'9c69d5e7-74ec-4f92-af3a-fef7d30c55bb'} />
|
||||
<button onClick={post}>Create</button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Questions;
|
13
src/components/post/UserAuth.jsx
Normal file
13
src/components/post/UserAuth.jsx
Normal file
@ -0,0 +1,13 @@
|
||||
import React from 'react';
|
||||
|
||||
const UserAuth = () => {
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default UserAuth;
|
58
src/components/post/Users.jsx
Normal file
58
src/components/post/Users.jsx
Normal file
@ -0,0 +1,58 @@
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { HttpApiMethods } from '../utils/FetchUtils';
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
export const PostUserModerator = () => {
|
||||
return (
|
||||
<div>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
const Users = () => {
|
||||
const formRef = useRef(null);
|
||||
const [dataIsLoad, setDataIsLoad] = useState(false);
|
||||
const [curentUser, setCurentUser] = useState(null);
|
||||
|
||||
let post = async (event) => {
|
||||
event.preventDefault();
|
||||
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')) {
|
||||
console.error('Ошибка: Не все поля формы заполнены');
|
||||
return;
|
||||
}
|
||||
|
||||
setDataIsLoad(false);
|
||||
httpApiMethods.PostUsers(formData).then(response => {
|
||||
console.log(response)
|
||||
setDataIsLoad(true);
|
||||
// let user_id = response.data.id;
|
||||
// console.log(response)
|
||||
// console.log(user_id)
|
||||
Cookies.set('userId', response.id);
|
||||
Cookies.set('token', response.token)
|
||||
// return user_id
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>Создание пользователя, получение ID в Cookies</h2>
|
||||
<div>{dataIsLoad ? "Данные успешно загружены" : ""}</div>
|
||||
<form ref={formRef} action=''>
|
||||
<input type="text" placeholder='fio' name='fio' />
|
||||
<input type="file" placeholder='avatar' name='avatar' />
|
||||
<input type="text" placeholder='username' name='username' />
|
||||
<input type="text" placeholder='specialities' name='specialities' />
|
||||
<input type="text" placeholder='telegramBotUrl' name='telegramBotUrl' />
|
||||
<button onClick={post}>Create</button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Users;
|
0
src/components/post/postReactions.jsx
Normal file
0
src/components/post/postReactions.jsx
Normal file
Reference in New Issue
Block a user