Skip to content

Commit

Permalink
Feat: #104 일정 목록에 대해 더미 처리에서 커스텀훅 처리로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
Seok93 committed Sep 6, 2024
1 parent b040240 commit ac9a5b0
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/pages/project/KanbanPage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useState } from 'react';
import { DragDropContext, Droppable, DropResult } from '@hello-pangea/dnd';
import ProjectStatusContainer from '@components/task/kanban/ProjectStatusContainer';
import { DND_DROPPABLE_PREFIX, DND_TYPE } from '@constants/dnd';
import deepClone from '@utils/deepClone';
import { parsePrefixId } from '@utils/converter';
import { TASK_SPECIAL_DUMMY } from '@mocks/mockData';
import { useReadStatusTasks } from '@hooks/query/useTaskQuery';
import useProjectContext from '@hooks/useProjectContext';
import type { Task, TaskListWithStatus } from '@/types/TaskType';

function createChangedStatus(statusTasks: TaskListWithStatus[], dropResult: DropResult) {
Expand Down Expand Up @@ -48,10 +48,10 @@ function createChangedTasks(statusTasks: TaskListWithStatus[], dropResult: DropR
return newStatusTasks;
}

// ToDo: TASK_SPECIAL_DUMMY 부분을 react query로 변경할 것, mutation 작업이 같이 들어가야함
// ToDo: DnD시 가시성을 위한 애니메이션 처리 추가할 것
export default function KanbanPage() {
const [statusTasks, setStatusTasks] = useState<TaskListWithStatus[]>(TASK_SPECIAL_DUMMY);
const { project } = useProjectContext();
const { statusTaskList } = useReadStatusTasks(project.projectId);

const handleDragEnd = (dropResult: DropResult) => {
const { source, destination, type } = dropResult;
Expand All @@ -60,14 +60,14 @@ export default function KanbanPage() {
if (source.droppableId === destination.droppableId && source.index === destination.index) return;

if (type === DND_TYPE.STATUS) {
const newStatusTasks = createChangedStatus(statusTasks, dropResult);
return setStatusTasks(newStatusTasks);
const newStatusList = createChangedStatus(statusTaskList, dropResult);
// return setStatusTasks(newStatusList);
}

if (type === DND_TYPE.TASK) {
const isSameStatus = source.droppableId === destination.droppableId;
const newStatusTasks = createChangedTasks(statusTasks, dropResult, isSameStatus);
return setStatusTasks(newStatusTasks);
const newStatusList = createChangedTasks(statusTaskList, dropResult, isSameStatus);
// return setStatusTasks(newStatusTasks);
}
};

Expand All @@ -80,7 +80,7 @@ export default function KanbanPage() {
ref={statusDropProvided.innerRef}
{...statusDropProvided.droppableProps}
>
{statusTasks.map((statusTask) => (
{statusTaskList.map((statusTask) => (
<ProjectStatusContainer key={statusTask.statusId} statusTask={statusTask} />
))}
{statusDropProvided.placeholder}
Expand Down

0 comments on commit ac9a5b0

Please sign in to comment.