Skip to content

Commit

Permalink
unsub button
Browse files Browse the repository at this point in the history
  • Loading branch information
Ko71k committed Nov 25, 2024
1 parent ef92d94 commit 29fe176
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions public/components/EventContentPage/EventContentPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,25 @@ export class EventContentPage {

eventAuthor.appendChild(subscribeButton);

const unSubscribeButton = document.createElement('button');
unSubscribeButton.className = 'buttonSubscribe';
unSubscribeButton.textContent = 'Отписаться';
unSubscribeButton.addEventListener("click", async () => {
const request = {
headers: {
},
credentials: 'include',
};
const path = `/profile/subscribe/${event.author}`;
try {
const response = await api.delete(path, request);
} catch (error) {
navigate('/login');
}
});

eventAuthor.appendChild(unSubscribeButton);

const authorText = document.createElement('div');
authorText.textContent = `Автор: ${event.author}`;
authorText.className = 'authorText';
Expand Down

0 comments on commit 29fe176

Please sign in to comment.