diff --git a/src/app/(content-layout)/[groupId]/tasklist/(tasklist)/page.tsx b/src/app/(content-layout)/[groupId]/tasklist/(tasklist)/page.tsx index d87af77d..252d8d86 100644 --- a/src/app/(content-layout)/[groupId]/tasklist/(tasklist)/page.tsx +++ b/src/app/(content-layout)/[groupId]/tasklist/(tasklist)/page.tsx @@ -66,7 +66,7 @@ export default async function Page({ params, searchParams }: Props) {

할 일

- + ); diff --git a/src/app/(content-layout)/[groupId]/tasklist/_tasklist/components/TaskLists.tsx b/src/app/(content-layout)/[groupId]/tasklist/_tasklist/components/TaskLists.tsx index 5a3d1251..946032cb 100644 --- a/src/app/(content-layout)/[groupId]/tasklist/_tasklist/components/TaskLists.tsx +++ b/src/app/(content-layout)/[groupId]/tasklist/_tasklist/components/TaskLists.tsx @@ -14,6 +14,9 @@ interface Props { export default function TaskLists({ taskLists, currentTaskListId }: Props) { const router = useRouter(); const searchParams = useSearchParams(); + const sortedTaskLists = taskLists.sort( + (a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime() + ); const handleClickChangeCurrentTaskList = async (taskList: TaskList) => { const params = new URLSearchParams(searchParams.toString()); @@ -27,7 +30,7 @@ export default function TaskLists({ taskLists, currentTaskListId }: Props) { return ( }>
- {taskLists.map((taskList) => { + {sortedTaskLists.map((taskList) => { return (

(tasks); const [isClient, setIsClient] = useState(false); @@ -26,7 +26,7 @@ export default function Tasks({ groupId, tasks, currentTaskList }: Props) { setIsClient(true); }, [tasks]); - const { sensors, handleDragEnd } = useDndKit(currentTasks, currentTaskList!, orderCurrentTasks); + const { sensors, handleDragEnd } = useDndKit(currentTasks, taskListId!, orderCurrentTasks); if (!isClient) return; @@ -43,7 +43,7 @@ export default function Tasks({ groupId, tasks, currentTaskList }: Props) { {currentTasks.map((task) => { return ( void ) { const { saveNewTaskOrder } = useTaskActions(); @@ -31,7 +31,7 @@ export default function useDndKit( const newIndex = currentTasks.findIndex((task) => task.id === over?.id); if (oldIndex !== -1 && newIndex !== -1) { sortCurrentTasks(arrayMove(currentTasks, oldIndex, newIndex)); - await saveNewTaskOrder(currentTaskList!.id, Number(active.id), newIndex); + await saveNewTaskOrder(taskListId, Number(active.id), newIndex); } } };