-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
146 additions
and
66 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
58 changes: 58 additions & 0 deletions
58
src/entities/task/ui/task-delete-button/ui/TaskDeleteButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Group, Button, ActionIcon, rem } from '@mantine/core'; | ||
import { notifications } from '@mantine/notifications'; | ||
import { IconQuestionMark, IconCheck, IconTrash } from '@tabler/icons-react'; | ||
import { type Task } from '@/shared/types'; | ||
import { taskModel } from '@/entities/task'; | ||
|
||
export interface TaskDeleteButtonProps { | ||
task: Task; | ||
} | ||
|
||
export const TaskDeleteButton = ({ task }: TaskDeleteButtonProps) => { | ||
const onClick = () => { | ||
taskModel.events.markTaskToRemove(task.id); | ||
|
||
notifications.show({ | ||
id: task.id, | ||
title: `Вы удалили задачу: ${task.title}`, | ||
message: ( | ||
<Group gap={rem(4)}> | ||
Хотите вернуть? | ||
<Button | ||
color="blue" | ||
variant="light" | ||
size="compact-xs" | ||
onClick={() => { | ||
taskModel.events.unmarkTaskToRemove(task.id); | ||
|
||
notifications.update({ | ||
id: task.id, | ||
title: `Вы вернули задачу: ${task.title}`, | ||
message: 'Задача возвращена', | ||
color: 'green', | ||
icon: <IconCheck />, | ||
withCloseButton: true, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
onClose: () => {}, | ||
}); | ||
}} | ||
> | ||
Да! | ||
</Button> | ||
</Group> | ||
), | ||
color: 'yellow', | ||
icon: <IconQuestionMark />, | ||
withCloseButton: false, | ||
onClose: () => { | ||
taskModel.events.removeTask(task.id); | ||
}, | ||
}); | ||
}; | ||
|
||
return ( | ||
<ActionIcon color="blue" onClick={onClick}> | ||
<IconTrash /> | ||
</ActionIcon> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './TaskDeleteButton'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters