add delete fix style

This commit is contained in:
cue
2024-04-03 03:48:00 +03:00
parent 635dfcd114
commit 4d6997457b
7 changed files with 99 additions and 15 deletions
@@ -8,9 +8,31 @@ import less from "./Admin.module.less";
import PlayerCard from "../../entities/PlayerCard/PlayerCard";
import { useTranslation } from "react-i18next";
import CreateTeam from "../../widgets/CreateTeams/CreateTeams";
import { UserList } from "../AdminEventPage/AdminEventAPI";
import { useEffect, useState } from "react";
const AdminPage = () => {
const { t } = useTranslation();
const [players, setPlayerList] = useState<Event[]>([]);
useEffect(() => {
var index = window.location.pathname.indexOf("/dash/admin/") + "/dash/admin/".length;
var result = window.location.pathname.substring(index);
UserList(result)
.then((data) => {
setPlayerList(data);
})
.catch((error) => {
console.error("Возникла ошибка с получением:", error);
});
}, []);
return (
<ResizablePanelGroup direction="horizontal">
<ResizablePanel defaultSize={95} maxSize={95}>
@@ -21,6 +43,9 @@ const AdminPage = () => {
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel>
{players.map((event) => (
<div>{event.first_name}</div>
))}
<PlayerCard />
<PlayerCard />
<PlayerCard />
@@ -1,5 +1,5 @@
import { FormEvent } from "react";
import { API_BASE, API_EVENT } from "../../app/APIurl";
import { API_BASE, API_EVENT, API_USERS } from "../../app/APIurl";
export const submitAddEvent = (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
@@ -56,6 +56,8 @@ export const eventList = () => {
console.error('Возникла ошибка с получением:', error);
});
}
//удалить ивент
export const deleteEvent = (id:string) => {
fetch(`${API_BASE}${API_EVENT}${id}`, {
method: "DELETE",
@@ -74,3 +76,33 @@ export const deleteEvent = (id:string) => {
console.error('Возникла ошибка с удалением:', error);
});
}
//получение списка юзеров
export const UserList = (id:string) => {
return fetch(`${API_BASE}${API_EVENT}${id}/${API_USERS}`, {
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);
return data
})
.catch(error => {
console.error('Возникла ошибка с получением:', error);
});
}
@@ -51,6 +51,14 @@
justify-content:space-between;
padding: 0;
}
.model-content{
display: flex;
flex-direction: column;
justify-content:center;
}
@media (max-width: 820px) {
.general-left{
width: 100%;
+3 -5
View File
@@ -51,7 +51,7 @@ const Main = () => {
<CardHeader className={less["header"]}>
<div className={less["up"]}>
<CardTitle className="p-0">{event.title}</CardTitle>
<CardDescription>Дата начала: {event.start_date}</CardDescription>
<CardDescription>Start Date: {event.start_date}</CardDescription>
</div>
{false && (
<Button size="icon" variant="ghost" onClick={() => deleteEvent(event.id)}><TrashIcon /></Button>
@@ -62,10 +62,10 @@ const Main = () => {
</CardContent>
<Dialog>
<DialogTrigger className="inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground hover:bg-primary/90 h-9 px-4 py-2">{t("respondRequest")}</DialogTrigger>
<DialogContent>
<DialogContent className={less["model-content"]}>
<DialogHeader>
<DialogTitle><h1 className={less["title-form"]}>{t("entrance")}</h1></DialogTitle>
<DialogDescription>
</DialogHeader>
<form className={less["input-form"]} onSubmit={(event) => submitRegister(event, navigate)}>
<div className={less["novis"]}><Input type="text" name="event" value={event.id} placeholder="Event" /></div>
<Input type="text" name="first_name" placeholder="First name" />
@@ -76,8 +76,6 @@ const Main = () => {
<Button>{t("buttonLoginInSystem")}</Button>
</form>
</DialogDescription>
</DialogHeader>
</DialogContent>
</Dialog>
@@ -5,6 +5,7 @@
}
.left{
width: 50%;
padding: 20px;
}
.right{
width: 50%;
@@ -12,4 +13,24 @@ width: 50%;
}
.card{
margin: 10px;
padding: 10px;
}
.input-form{
display: flex;
flex-direction: column;
gap: 8px;
}
.title{
padding: 0;
}
.up{
display: flex;
flex-direction: column;
}
.header{
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
padding: 0;
}
@@ -9,7 +9,7 @@ import { Link } from "react-router-dom";
import { ToastAction } from "../../shared/ui/toast";
import { useToast } from "../../shared/ui/use-toast";
import { buttonVariants } from "../../ui/button";
import { addEvent, submitRegister } from "../../widgets/Header/AuthAPI";
import { addEvent, deleteEvent, submitRegister } from "../../widgets/Header/AuthAPI";
import {
Card,
CardContent,
@@ -53,7 +53,7 @@ const SkillTree = () => {
<Input type="date" name="start_date" placeholder="Start date" />
<Input type="date" name="end_date" placeholder="End date" />
<Textarea name="description" placeholder="Description" />
<Switch/>
<Switch name="is_online"/>
<Button>{t("buttonLoginInSystem")}</Button>
</form>
</div>
@@ -63,11 +63,11 @@ const SkillTree = () => {
<div className="flex flex-col">
<CardHeader className={less["header"]}>
<div className={less["up"]}>
<CardTitle className="p-0">{event.title}</CardTitle>
<CardDescription>Дата начала: {event.start_date}</CardDescription>
<CardTitle className={less["title"]}>{event.title}</CardTitle>
<CardDescription>Start date: {event.start_date}</CardDescription>
</div>
{false && (
<Button size="icon" variant="ghost" ><TrashIcon /></Button>
{true && (
<Button size="icon" variant="ghost"onClick={() =>{deleteEvent(event.id)}} ><TrashIcon /></Button>
)}
</CardHeader>
<CardContent className="p-0 mt-4" >
+3 -3
View File
@@ -19,7 +19,7 @@ i18n.use(initReactI18next).init({
LightTheme: "Светлая",
DarkTheme: "Темная",
SystemTheme: "Тема устройства",
entrance: "Вход",
entrance: "Подать заявку",
login: "Авторизация",
registration: "Регистрация",
loginHeader: "Введите адрес электронной почты и пароль, чтобы начать.",
@@ -58,7 +58,7 @@ i18n.use(initReactI18next).init({
LightTheme: "Light",
DarkTheme: "Dark",
SystemTheme: "System Theme",
entrance: "Sign in",
entrance: "Submit An Application",
login: "Log in",
registration: "Sign up",
loginHeader: " Enter your email address and password to get started.",
@@ -94,7 +94,7 @@ i18n.use(initReactI18next).init({
LightTheme: "光",
DarkTheme: "黑暗",
SystemTheme: "系统主题",
entrance: "登入您的帐户",
entrance: "递交申请",
login: "登录",
registration: "登记注册",
loginHeader: "请输入您的电子邮件地址和密码,开始更改.",