Skip to content

Commit

Permalink
[FE] comment: 필요 없는 코드 제거 (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
gunoc committed Jul 18, 2023
1 parent 8688042 commit cfedc98
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
30 changes: 16 additions & 14 deletions fe/src/components/main/ColumnList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ type AddTaskType = TaskType & { processId: number };
type EditTaskType = { taskId: number; title: string; contents: string };

export const ColumnList = () => {

const horizontalScrollRef = useRef(null);
const { todoListData, setTodoListData } = useData();
// const [todoListData, setTodoListData] = useState<TodoItemType[] | null>(null);


useEffect(() => {
const fetchTodoList = async () => {
const response = await fetch('/todolist');
Expand Down Expand Up @@ -63,16 +61,23 @@ export const ColumnList = () => {
});
};

const handleTitleChange = (newName: string, processId: number) => {
// const newName = e.target.value;
setTodoListData((prevData) => {
if (!prevData) return null;

const handleTitleChange = (e, processId) => {
const newName = e.target.value;
setTodoListData(
(prevData) =>
prevData &&
prevData.map((item) =>
item.processId === processId ? { ...item, name: newName } : item,
),
);
return prevData.map((item) =>
item.processId === processId ? { ...item, name: newName } : item,
);
});

// setTodoListData(
// (prevData) =>
// prevData &&
// prevData.map((item) =>
// item.processId === processId ? { ...item, name: newName } : item,
// ),
// );
};

const handleNewColumn = () => {
Expand Down Expand Up @@ -141,12 +146,9 @@ export const ColumnList = () => {
processId={item.processId}
onNewTask={handleNewTask}
onTaskDelete={handleTaskDelete}

onTitleChange={handleTitleChange}
onColumnDelete={handleColumnDelete}

onTaskEdit={handleTaskEdit}

/>
))}
</ColumnLayout>
Expand Down
11 changes: 7 additions & 4 deletions fe/src/components/main/ColumnTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ type ColumnTitleProps = {
title: string;
numberOfTasks: number;
onAddClick?: () => void;
onTitleChange: (e, processId: number) => void;
// onTitleChange: (e, processId: number) => void;
onTitleChange: (newName: string, processId: number) => void;
processId: number;
onColumnDelete: (processId: number) => void;
};
Expand Down Expand Up @@ -36,16 +37,18 @@ export const ColumnTitle: React.FC<ColumnTitleProps> = ({
const handleEditTitle = () => {
setIsEditing((prev) => !prev);
};

const handleTitleChange = (e) => {
setNewTitle(e.target.value);
};

const handleBlur = (e) => {
if (e.target.value.length === 0) return;
handleSubmit(e, processId);
handleSubmit(processId);
};

const handleSubmit = async (e, processId: number) => {
// const handleSubmit = async (e, processId: number) => {
const handleSubmit = async (processId: number) => {
console.log('해당 Process ID: ', processId);
console.log('Submitted 컬럼 title: ', newTitle);

Expand All @@ -63,7 +66,7 @@ export const ColumnTitle: React.FC<ColumnTitleProps> = ({

console.log(responseData);
setIsEditing((prev) => !prev);
onTitleChange(e, processId);
onTitleChange(newTitle, processId);
};

const handleDelete = async () => {
Expand Down

0 comments on commit cfedc98

Please sign in to comment.