Skip to content

Commit

Permalink
refactor createListItems
Browse files Browse the repository at this point in the history
  • Loading branch information
narthur committed Nov 8, 2022
1 parent 274c1fc commit 3ba0102
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/components/organisms/TaskList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ const TaskList = ({ newTask }: TaskListProps): JSX.Element => {
const filtered = filters ? sorted.filter((t) => filters[t.status]) : sorted;

const { entries: newEntries, newTaskIndex: taskIndexUpdate } =
createListItems(filtered, newTask);
createListItems({
sortedTasks: filtered,
newTask,
});

setEntries(newEntries);
setNewTaskIndex(taskIndexUpdate);
Expand Down
10 changes: 6 additions & 4 deletions src/lib/createListItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ const isNewTask = (t: TaskType, n: TaskType | undefined): boolean => {

type Entries = (TaskType | string)[];

export default function createListItems(
sortedTasks: TaskType[],
newTask: TaskType | undefined
): {
type Options = {
sortedTasks: TaskType[];
newTask: TaskType | undefined;
};

export default function createListItems({ sortedTasks, newTask }: Options): {
entries: Entries;
newTaskIndex: number | undefined;
} {
Expand Down

1 comment on commit 3ba0102

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.