Merge branch 'main' of https://github.com/Central-University-IT-prod/PROD-Animulichki-SkillHub
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
import { Input } from "../../ui/input";
|
import { Input } from "../../ui/input";
|
||||||
import VacancyCard from "../../entities/VacancyCard/VacancyCard";
|
|
||||||
import { Textarea } from "../../shared/ui/textarea";
|
import { Textarea } from "../../shared/ui/textarea";
|
||||||
import { Button } from "../../shared/ui/button";
|
import { Button } from "../../shared/ui/button";
|
||||||
import less from "./SkillTree.module.less"
|
import less from "./SkillTree.module.less"
|
||||||
import { Switch } from "../../shared/ui/switch";
|
import { Switch } from "../../shared/ui/switch";
|
||||||
import { addEvent, submitRegister } from "../../widgets/Header/AuthAPI";
|
import { addEvent, deleteEvent, submitRegister } from "../../widgets/Header/AuthAPI";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
@@ -62,8 +61,8 @@ const SkillTree = () => {
|
|||||||
<CardTitle className="p-0">{event.title}</CardTitle>
|
<CardTitle className="p-0">{event.title}</CardTitle>
|
||||||
<CardDescription>Дата начала: {event.start_date}</CardDescription>
|
<CardDescription>Дата начала: {event.start_date}</CardDescription>
|
||||||
</div>
|
</div>
|
||||||
{false && (
|
{true && (
|
||||||
<Button size="icon" variant="ghost" ><TrashIcon /></Button>
|
<Button size="icon" variant="ghost" onClick={() => {deleteEvent(event.id)}}><TrashIcon /></Button>
|
||||||
)}
|
)}
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="p-0 mt-4" >
|
<CardContent className="p-0 mt-4" >
|
||||||
|
|||||||
@@ -105,3 +105,31 @@ export const addEvent = (e: FormEvent<HTMLFormElement>) => {
|
|||||||
console.error('Возникла ошибка с регой:', error);
|
console.error('Возникла ошибка с регой:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
export const deleteEvent = (id:string) => {
|
||||||
|
|
||||||
|
fetch(`${API_BASE}${API_EVENT}${id}`, {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
console.log(response.status);
|
||||||
|
if (response.ok) {
|
||||||
|
console.log('Удален:', response.headers.get('Location'));
|
||||||
|
window.location.reload();
|
||||||
|
return response.json();
|
||||||
|
} else {
|
||||||
|
return response.text().then(errorMessage => {
|
||||||
|
throw new Error('Код ошибки: ' + response.status + '. ' + errorMessage + '. Дата ошибки: ' + response.headers.get('Date'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
console.log('Успешно:', data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Возникла ошибка с удалением:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user