-
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
18 changed files
with
145 additions
and
39 deletions.
There are no files selected for viewing
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.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './TaskForm'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export * from './tasks-filter'; | ||
export * from './filtered-tasks'; | ||
export * from './task-view'; | ||
export * from './task-create-form'; | ||
export * from './task-edit-form'; |
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 './ui'; |
24 changes: 24 additions & 0 deletions
24
src/features/task/ui/task-create-form/ui/TaskCreateForm.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,24 @@ | ||
import { useCallback } from 'react'; | ||
import { type ContextModalProps } from '@mantine/modals'; | ||
import { TaskForm, taskModel, type TaskFormValues } from '@/entities/task'; | ||
|
||
export const TaskCreateForm = ({ id, context }: ContextModalProps) => { | ||
const onSubmit = useCallback( | ||
(values: TaskFormValues) => | ||
new Promise<void>((resolve) => { | ||
taskModel.events.addTask({ | ||
title: values.title, | ||
description: values.description, | ||
priority: values.priority, | ||
expiresIn: values.expiresIn?.toISOString(), | ||
}); | ||
|
||
context.closeContextModal(id); | ||
|
||
resolve(); | ||
}), | ||
[id, context], | ||
); | ||
|
||
return <TaskForm submitText="Создать" onSubmit={onSubmit} />; | ||
}; |
File renamed without changes.
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 './ui'; |
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,36 @@ | ||
import { useCallback } from 'react'; | ||
import { type ContextModalProps } from '@mantine/modals'; | ||
import { TaskForm, taskModel, type TaskFormValues } from '@/entities/task'; | ||
import { type TaskId } from '@/shared/types'; | ||
|
||
export interface TaskEditFormProps { | ||
taskId: TaskId; | ||
} | ||
|
||
export const TaskEditForm = ({ | ||
id, | ||
context, | ||
innerProps: { taskId }, | ||
}: ContextModalProps<TaskEditFormProps>) => { | ||
const task = taskModel.selectors.useTask(taskId); | ||
|
||
const onSubmit = useCallback( | ||
(values: TaskFormValues) => | ||
new Promise<void>((resolve) => { | ||
taskModel.events.modifyTask({ | ||
id: taskId, | ||
title: values.title, | ||
description: values.description, | ||
priority: values.priority, | ||
expiresIn: values.expiresIn?.toISOString(), | ||
}); | ||
|
||
context.closeContextModal(id); | ||
|
||
resolve(); | ||
}), | ||
[taskId, id, context], | ||
); | ||
|
||
return <TaskForm data={task} submitText="Изменить" onSubmit={onSubmit} />; | ||
}; |
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 './TaskEditForm'; |
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