okey
This commit is contained in:
@@ -4,6 +4,7 @@ import less from "./Admin.module.less"
|
||||
import PlayerCard from "../../entities/PlayerCard/PlayerCard"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import CreateTeam from "../../widgets/CreateTeams/CreateTeams"
|
||||
import { Link } from "react-router-dom"
|
||||
|
||||
const AdminPage = () =>{
|
||||
const { t } = useTranslation();
|
||||
@@ -11,7 +12,8 @@ const AdminPage = () =>{
|
||||
<ResizablePanelGroup direction="horizontal">
|
||||
<ResizablePanel defaultSize={95} maxSize={95}>
|
||||
<div className={less["main-admin"]}>
|
||||
<Button>{t("EditTree")}</Button>
|
||||
<Button asChild><Link to={"skill-tree"}>{t("EditTree")}</Link></Button>
|
||||
|
||||
<CreateTeam/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import { FormEvent } from "react";
|
||||
import { API_BASE, API_CREATE_EVENT } from "../../app/APIurl";
|
||||
|
||||
export const submitAddEvent = (e: FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
const formData = new FormData(e.currentTarget);
|
||||
const formProps = Object.fromEntries(formData);
|
||||
console.log(formProps)
|
||||
|
||||
|
||||
fetch(`${API_BASE}${API_CREATE_EVENT}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(formProps) ,
|
||||
})
|
||||
.then(response => {
|
||||
|
||||
console.log(response.status);
|
||||
|
||||
if (response.ok) {
|
||||
console.log('Создан:', response.headers.get('Location'));
|
||||
return response.json();
|
||||
} else {
|
||||
|
||||
throw new Error('Код ошибки: ' + response.status);
|
||||
}
|
||||
})
|
||||
.then(data => {
|
||||
console.log('Успешно:', data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Возникла ошибка с созданием:', error);
|
||||
});
|
||||
}
|
||||
|
||||
export const eventList = () => {
|
||||
|
||||
|
||||
fetch(`${API_BASE}${API_CREATE_EVENT}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then(response => {
|
||||
|
||||
console.log(response.status);
|
||||
|
||||
if (response.ok) {
|
||||
console.log('Получен:', response.headers.get('Location'));
|
||||
return response.json();
|
||||
} else {
|
||||
|
||||
throw new Error('Код ошибки: ' + response.status);
|
||||
}
|
||||
})
|
||||
.then(data => {
|
||||
console.log('Успешно:', data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Возникла ошибка с получением:', error);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
.main-admin{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 80%;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 50px;
|
||||
margin-top: 40px;
|
||||
height: 70vh;
|
||||
}
|
||||
.admin-event__page{
|
||||
display: flex;
|
||||
}
|
||||
.cont_1{
|
||||
width: 50%;
|
||||
border-right-width: 1px;
|
||||
height: 100vh;
|
||||
padding: 20px;
|
||||
|
||||
}
|
||||
.cont_2{
|
||||
width: 50%;
|
||||
padding: 20px;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.input-form{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
}
|
||||
.liner-block{
|
||||
display: flex;
|
||||
|
||||
align-items: center;
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import { Input } from "../../shared/ui/input";
|
||||
import VacancyCard from "../../entities/VacancyCard/VacancyCard";
|
||||
import less from "./AdminEventPage.module.less"
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button } from "../../shared/ui/button";
|
||||
import { Textarea } from "../../shared/ui/textarea";
|
||||
import { eventList, submitAddEvent } from "./AdminEventAPI";
|
||||
import { Switch } from "../../shared/ui/switch";
|
||||
import { Label } from "../../shared/ui/label";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
|
||||
|
||||
const AdminEventPage = () =>{
|
||||
const { t } = useTranslation();
|
||||
let wfew = JSON.stringify(eventList());
|
||||
console.log(typeof wfew);
|
||||
console.log(wfew );
|
||||
|
||||
|
||||
const [events, setEvents] = useState<Event[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchData();
|
||||
}, []);
|
||||
|
||||
const fetchData = () => {
|
||||
eventList() // Вызываем функцию eventList из файла api.ts
|
||||
.then((data: Event[]) => {
|
||||
setEvents(data); // Устанавливаем полученные данные в состояние
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.error('Произошла ошибка:', error); // Обрабатываем ошибку, если она возникла
|
||||
});
|
||||
};
|
||||
|
||||
return(
|
||||
<div className={less["admin-event__page"]}>
|
||||
<div className={less["cont_1"]}>
|
||||
<form className={less["input-form"]} onSubmit={(event) => submitAddEvent(event)}>
|
||||
<h1 className={less["title-titleform"]}>{t("createEvent")}</h1>
|
||||
<Input type="text" name="title" placeholder="Event name" />
|
||||
<Input type="date" name="start_date" placeholder="Start Date" />
|
||||
<Input type="date" name="end_date" placeholder="End Date" />
|
||||
|
||||
<Textarea name="description" placeholder="About Event" />
|
||||
<div className={less["liner-block"]}>
|
||||
<Switch name="is_online" />
|
||||
<Label htmlFor="airplane-mode">Онлайн мероприятие</Label>
|
||||
</div>
|
||||
<Button>{t("createEvent")}</Button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<Button onClick={eventList}>{t("createEvent")}</Button>
|
||||
|
||||
<div className={less["cont_2"]}>
|
||||
{events.map((event) => (
|
||||
<li key={event.created_at}>
|
||||
<div>Название: {event.title}</div>
|
||||
<div>Дата: {event.updated_at}</div>
|
||||
{/* Добавьте другие свойства вашего объекта, если они есть */}
|
||||
</li>
|
||||
))}
|
||||
<VacancyCard></VacancyCard>
|
||||
<VacancyCard></VacancyCard>
|
||||
<VacancyCard></VacancyCard>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export default AdminEventPage
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
const SkillTree = () => {
|
||||
return (
|
||||
<div style={{height: '100%'}}>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default SkillTree;
|
||||
Reference in New Issue
Block a user