Skip to content

Conversation

@kangtayie
Copy link
Contributor

1. 무엇을??

기존 Todo List 구현하기 과제에서 Edit, Cancel, Save 기능을 구현하였습니다.
tasks 상태를 localStorage에 저장하여 브라우저를 닫았다가 다시 열어도 데이터가 유지되도록 하였습니다.

2. 어떤 작업을 하였나요??

todolist 컴포넌트에서 isEditing 상태를 추가하고 Edit 버튼 클릭시 cancel/save버튼 렌더링,
cancel 버튼 누르면 취소, save버튼 누르면 수정된 이름으로 반영
tasks 상태를 localStorage에 저장

3. 스크린샷

image
image
image

@kangtayie kangtayie self-assigned this Apr 29, 2025
Copy link
Member

@yezzan9 yezzan9 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다 태이님!
현재 코드를 보니 prettier가 제대로 설정이 안 되어있는 것 같아요💦
확인 후 설정부탁드립니다 !!

Comment on lines +85 to +98
const TodoList = ({ todos, setTodos, activeCategory }) => {
const [editTexts, setEditTexts] = useState({});

const handleDelete = (id) => {
setTodos(todos.filter(todo => todo.id !== id));
};

const handleToggleComplete = (id) => {
setTodos(
todos.map(todo =>
todo.id === id ? { ...todo, completed: !todo.completed } : todo
)
);
};
Copy link
Member

Choose a reason for hiding this comment

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

이 부분 들여쓰기가 4칸으로 되어있는 것 같아요 ! 2칸으로 수정해주세용👀

Comment on lines +148 to +190
<TodoListContainer>
<StyledText>{todos.filter(todo => !todo.completed).length} tasks remaining</StyledText>
<div className="task-list">
{filteredTodos.map(todo => (
<TaskItem key={todo.id}>
{todo.isEditing ? (
<>
<TaskTop style={{ flexDirection: "column", alignItems:"flex-start"}}>
<div style={{marginBottom: "8px", fontWeight:"bold"}}>
New name for <span style={{color: "#555"}}>{todo.text}</span>
</div>

<input
type="text"
value={editTexts[todo.id] || ''}
onChange={(e) => handleEditChange(todo.id, e.target.value)}
style={{ width: "400px", padding: "8px", fontSize: "16px" }}
/>
</TaskTop>

<TaskActions>
<CancelButton onClick={() => handleCancel(todo.id)}>Cancel</CancelButton>
<SaveButton onClick={() => handleSave(todo.id)}>Save</SaveButton>
</TaskActions>
</>
) : (
<>
<TaskTop>
<StyledCheckbox
checked={todo.completed}
onChange={() => handleToggleComplete(todo.id)}
/>
<span style={{ textDecoration: todo.completed ? 'line-through' : 'none' }}>
{todo.text}
</span>
</TaskTop>
<TaskActions>
<EditButton onClick={() => handleEdit(todo.id, todo.text)}>Edit</EditButton>
<DeleteButton onClick={() => handleDelete(todo.id)}>Delete</DeleteButton>
</TaskActions>
</>
)}
</TaskItem>
Copy link
Member

Choose a reason for hiding this comment

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

이 부분도요!🥺

Comment on lines +160 to +165
<input
type="text"
value={editTexts[todo.id] || ''}
onChange={(e) => handleEditChange(todo.id, e.target.value)}
style={{ width: "400px", padding: "8px", fontSize: "16px" }}
/>
Copy link
Member

Choose a reason for hiding this comment

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

기존에 구현했던 Input 컴포넌트를 재사용하도록 수정하면 더 좋을 것 같아요!

@kangtayie kangtayie changed the base branch from main to 강태이/main May 27, 2025 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants