Skip to content

Conversation

@imakerjun
Copy link
Collaborator

No description provided.

@imakerjun imakerjun changed the title Rlatmdgns94 [10기 김승훈] TodoList with Ajax Jul 19, 2021
Copy link

@kimjanghu kimjanghu left a comment

Choose a reason for hiding this comment

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

구현 잘봤습니다!! 한 주 동안 고생많으셨습니다 👍

this.userList = new UserList({
userSelecteHandler: async ({ target }) => {
const id = target.dataset.id;
if (id === undefined || id === '') return;

Choose a reason for hiding this comment

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

if (!id) return 만해도 될 것 같아요

Choose a reason for hiding this comment

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

감사합니다 !

Comment on lines +55 to +57
const name = prompt('추가하고 싶은 이름을 입력해주세요.');
if (name.length < 2) {
alert('이름은 최소 2글자 이상이어야 합니다.');

Choose a reason for hiding this comment

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

2, prompt, alert안에 있는 것들은 모듈화, 상수화해서 사용하면 좋을 것 같아요.

Comment on lines +71 to +77
deleteTodo: async ({ target }) => {
const userId = this.currentUser._id;
const todoId = target.closest('li').dataset.id;
if (!isClassContains(target, 'destroy')) return;
await setDeleteTodo(userId, todoId);
this.render();
},

Choose a reason for hiding this comment

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

TodoList에서 함수를 정의하지 않고 이런식으로 함수를 정의해서 내려보내는 이유가 있을까요?
App.js가 너무 비대해지는거 같아요.

Copy link

@rlatmdgns rlatmdgns Jul 19, 2021

Choose a reason for hiding this comment

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

함수를 정의해서 내려보내는게 명확할 것 같다는 피드백을 받아서 이렇게 작업을 해보았습니다 !

App.js가 너무 비대해지는거 같아요.
app.js가 너무 많은 역할을 하는 것 같아요.

이거 대한 생각이 제가 짧았던 거 같네여 ㅠㅠ 좋은 피드백 ! 감사합니다.
개선해 보겠습니다

Comment on lines +33 to +39
this.render = async () => {
this.userTodoData = await getUserTodos(this.currentUser._id);
this.userList.render(this.users, this.currentUser);
this.userName.render(this.currentUser);
this.todoList.render(this.userTodoData);
this.todoCount.render(this.userTodoData);
};

Choose a reason for hiding this comment

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

app.js가 너무 많은 역할을 하는 것 같아요. store의 역할인것 같은데 분리하는 것도 좋아보입니다.

Comment on lines +13 to +19
try {
const response = await fetch(`${BASE_URL}/${data}`);
return response.json();
} catch (error) {
console.error(error);
}
};

Choose a reason for hiding this comment

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

반복되는 코드가 많은 것 같습니다. request라는 함수를 만들어 사용하는 것도 좋아보여요

Comment on lines +33 to +37
method: 'POST',
headers: {
'content-type': 'application/json',
},
body: JSON.stringify(data),

Choose a reason for hiding this comment

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

이 부분도 따로 빼서 message를 만들면 좋을 것 같아요!

},
});
} catch (error) {
console.error(error);

Choose a reason for hiding this comment

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

저도 못한 부분이긴 하지만, error에 대한 처리를 좀 더 명확하게 하면 좋을 것같아요! modal이라던지 alert이라던지..!!

countContainer.addEventListener('click', clear);
};
function filterHandler(event) {
event.preventDefault();

Choose a reason for hiding this comment

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

submit을 사용하지 않는데 preventDefault를 사용하시는 이유가 있나요?

Choose a reason for hiding this comment

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

필터 a태그 클릭 시 href 사용되지 않게 하려고 했습니다.

용도에 맞게 버튼 태그를 사용하면 event.preventDefault(); 사용하지 않아도될 것 같네여

const filterButtons = $all('.filters li a');
const [status] = event.target.classList;
const targetButton = $(`a.${status}`);
Object.keys(filterButtons).map(key => filterButtons[key].classList.remove('selected'));

Choose a reason for hiding this comment

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

전체적인 로직은 파악할 수 없지만 $all이 array형태로 return 되는데 Object.keys를 사용하는 이유가 있을까요?

filterButtons.forEach((item) => item.classList.remove('selected'))

이런식으로 하는건 어떨까요

Comment on lines +9 to +22
${
priority === 'NONE'
? `
<select class="chip select">
<option value="0" selected="">순위</option>
<option value="1">1순위</option>
<option value="2">2순위</option>
</select>
`
: `
<span class="chip ${priority === 'FIRST' ? 'primary' : 'secondary'}">
${priority === 'FIRST' ? '1' : '2'}순위
</span>`
}

Choose a reason for hiding this comment

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

가독성이 좋지 않아보여요! 따로 함수로 빼서 작성하는 것도 여러 방법 중 하나 입니다.

Copy link

@HongJungKim-dev HongJungKim-dev left a comment

Choose a reason for hiding this comment

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

고생많으셨습니다 많은 도움이 되었습니다!

Comment on lines +5 to +29
<li data-id=${_id} class=${isCompleted ? 'completed' : ''}>
<div class="view">
<input class="toggle" type="checkbox" ${isCompleted ? 'checked' : ''}>
<label class="label">
${
priority === 'NONE'
? `
<select class="chip select">
<option value="0" selected="">순위</option>
<option value="1">1순위</option>
<option value="2">2순위</option>
</select>
`
: `
<span class="chip ${priority === 'FIRST' ? 'primary' : 'secondary'}">
${priority === 'FIRST' ? '1' : '2'}순위
</span>`
}
${contents}
</label>
<button class="destroy"></button>
</div>
<input class="edit" value="${contents}">
</li>
`;

Choose a reason for hiding this comment

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

20줄이 넘어서 읽기 힘든점이 있는것 같습니다. 큰 내용을 차지하는 태그를 함수로 빼는것은 어떤가요?

Comment on lines +40 to +44
todoList.addEventListener('click', deleteTodo);
todoList.addEventListener('click', completeToggle);
todoList.addEventListener('change', prioritySelect);
todoList.addEventListener('dblclick', editTodo);
todoList.addEventListener('keydown', updateTodo);

Choose a reason for hiding this comment

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

같은 동작이 반복되는것 같습니다!

Comment on lines +10 to +13




Choose a reason for hiding this comment

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

불필요한 공백이 있는것 같습니다.

@@ -0,0 +1,2 @@
import App from './App.js';
new App().init() No newline at end of file

Choose a reason for hiding this comment

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

개행이 필요한것 같습니다.

this.render = user => {
const userName = document.querySelector('#user-title strong');
const userName = $('#user-title strong');
if (user.name === '') return;

Choose a reason for hiding this comment

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

if(user.name === '') return;
const userName = $('#user-title strong');
실패 코드를 빠르게 리턴

src/api.js Outdated
@@ -0,0 +1,26 @@
const BASE_URL = "https://js-todo-list-9ca3a.df.r.appspot.com/api"

export const getUsersList = async() => {

Choose a reason for hiding this comment

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

config 로 따로 분리

src/api.js Outdated
}
}

export const setUser = async(data) => {

Choose a reason for hiding this comment

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

api.js
user, todo 분리가 필요할 것 같습니다.

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.

4 participants