Skip to content

Commit

Permalink
Изменяет логику удаления задачи
Browse files Browse the repository at this point in the history
  • Loading branch information
Seasle committed Jan 1, 2024
1 parent a82cfb1 commit 053a451
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/entities/task/ui/task-delete-button/ui/TaskDeleteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ export interface TaskDeleteButtonProps {

export const TaskDeleteButton = ({ task }: TaskDeleteButtonProps) => {
const onClick = () => {
taskModel.events.markTaskToRemove(task.id);
let needRemove = true;

taskModel.events.markTaskToRemove(task.id);
notifications.show({
id: task.id,
title: `Вы удалили задачу: ${task.title}`,
Expand All @@ -23,17 +24,15 @@ export const TaskDeleteButton = ({ task }: TaskDeleteButtonProps) => {
variant="light"
size="compact-xs"
onClick={() => {
taskModel.events.unmarkTaskToRemove(task.id);
needRemove = false;

notifications.update({
id: task.id,
taskModel.events.unmarkTaskToRemove(task.id);
notifications.hide(task.id);
notifications.show({
title: `Вы вернули задачу: ${task.title}`,
message: 'Задача возвращена',
color: 'green',
icon: <IconCheck />,
withCloseButton: true,
// eslint-disable-next-line @typescript-eslint/no-empty-function
onClose: () => {},
});
}}
>
Expand All @@ -43,8 +42,11 @@ export const TaskDeleteButton = ({ task }: TaskDeleteButtonProps) => {
),
color: 'yellow',
icon: <IconQuestionMark />,
withCloseButton: false,
onClose: () => {
if (!needRemove) {
return;
}

taskModel.events.removeTask(task.id);
},
});
Expand Down

0 comments on commit 053a451

Please sign in to comment.