-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(store): finish migration to redux-toolkit
- Loading branch information
Showing
14 changed files
with
468 additions
and
511 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { v4 as uuid } from "uuid"; | ||
import type { Task } from "./types"; | ||
|
||
type CreateTaskParams = Pick<Task, "text"> & | ||
Partial<Pick<Task, "description">>; | ||
type EditableTaskParams = Partial<Omit<Task, "_id">>; | ||
|
||
export const createTask = ({ | ||
text, | ||
description = "", | ||
}: CreateTaskParams): Task => { | ||
return { | ||
_id: uuid(), | ||
text, | ||
description, | ||
done: false, | ||
}; | ||
}; | ||
|
||
export const editTask = ( | ||
task: Task, | ||
changedFields: EditableTaskParams | ||
): Task => { | ||
return { ...task, ...changedFields }; | ||
}; |
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,43 @@ | ||
import { Task, TaskList } from "./types"; | ||
import { v4 as uuid } from "uuid"; | ||
|
||
type CreateTaskListParams = Pick<TaskList, "title" | "priority">; | ||
|
||
export const createTaskList = ({ | ||
title, | ||
priority, | ||
}: CreateTaskListParams): TaskList => { | ||
return { | ||
_id: uuid(), | ||
title, | ||
cards: [], | ||
priority, | ||
}; | ||
}; | ||
|
||
export const addTaskToList = ( | ||
taskList: TaskList, | ||
task: Task | ||
): TaskList => { | ||
return { | ||
...taskList, | ||
cards: [...taskList.cards, task], | ||
}; | ||
}; | ||
|
||
export const removeTaskFromList = ( | ||
taskList: TaskList, | ||
taskId: string | ||
): TaskList => { | ||
return { | ||
...taskList, | ||
cards: taskList.cards.filter((task) => task._id !== taskId), | ||
}; | ||
}; | ||
|
||
export const setListPriority = ( | ||
taskList: TaskList, | ||
priority: boolean | ||
): TaskList => { | ||
return { ...taskList, priority }; | ||
}; |
Oops, something went wrong.