New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
To do day2 #2
To do day2 #2
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @omar25ahmed,
📝👌 Your project highlights 🔥😎
- General Requirements 🔥
- Add, Remove, and Edit methods were implemented perfectly 💪
Great job so far!
There are some issues that you still need to work on to go to the next project but you are almost there!
Required Changes ♻️
Check the comments under the review.
Optional suggestions
Every comment with the [OPTIONAL] prefix is not crucial enough to stop the approval of this PR. However, I strongly recommend you to take them into account as they can make your code better.
Cheers and Happy coding!👏👏👏
Feel free to leave any questions or comments in the PR thread if something is not 100% clear.
Please, do not open a new Pull Request for re-reviews. You should use the same Pull Request submitted for the first review, either valid or invalid unless it is requested otherwise.
As described in the Code reviews limits policy you have a limited number of reviews per project (check the exact number in your Dashboard). If you think that the code review was not fair, you can request a second opinion using this form
@@ -1,14 +1,135 @@ | |||
import _ from 'lodash'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When adding or deleting a task from your to-do list its important that the tasks property index is always set to the value of the new array length.
As you can see in the image, After playing around adding, deleting, and editing tasks, the left task index is 3 when it should be 1. Kindly make the necessary changes to that your app works as mentioned 🔥
The mentioned issue with the indexes of your tasks is causing another one. If you create a single task and you remove it, works perfectly. If you create a bunch of tasks and then delete the first-created ones until only the last one is left and you try to delete it doesn't work properly. After the page is refreshed, the task is still there. I assume its something to do with the index not matching the one you think you are removing 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @omar25ahmed 👋,
Great work on making the changes requested by a previous reviewer 👏
You've done well implementing some of the requested changes, but there are still some which aren't addressed yet.
Required Changes ♻️
- [ ] It would be nice to implement the first suggested change by the other reviewer. Kindly transfer all the functions for adding, editing, and removing tasks to another file, then import that file into your index.js file.
Kindly check the comments under the review for further suggestions/required changes. 👍
Optional suggestions
N/A
Cheers and Happy coding!👏👏👏
Feel free to leave any questions or comments in the PR thread if something is not 100% clear.
Please, do not open a new Pull Request for re-reviews. You should use the same Pull Request submitted for the first review, either valid or invalid unless it is requested otherwise.
As described in the Code reviews limits policy you have a limited number of reviews per project (check the exact number in your Dashboard). If you think that the code review was not fair, you can request a second opinion using this form.
el.dataset.index = task.index - 1; | ||
task.updatedIndex = task.index - 1; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I can see that you are trying to implement changes from the previous reviewer. You do not need to add an
updatedIndex
key when you delete an item, all that is required for you is to rearrange the values of theindex
key of each object in the array.
Hint:
const filteredArray = array.filter((obj) => obj.completed !== true);
filteredArray.forEach((obj, index) => {
obj.index = index + 1;
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏽 This works fine now
function prepareEdit(task, btn) { | ||
btn.addEventListener('click', () => { | ||
const el = document.querySelector(`[data-index="${task.index}"]`); | ||
const p = el.children[1]; | ||
const input = document.createElement('input'); | ||
input.type = 'text'; | ||
input.value = p.textContent; | ||
input.id = task.index; | ||
el.insertBefore(input, p); | ||
el.removeChild(p); | ||
input.focus(); | ||
input.select(); | ||
input.classList.add('edit'); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I like the way you implemented the edit. However, when I edit a task, the edited description is not saved to the localStorage, so when I reload the page, it shows undefined as the value for the description. What you want to do is to edit the value of the description and save the array with the edited value to the localStorage.
Hint: You should filter through the array, select that particular object, set the value of the description
key of that object to the input value then save the whole array to the local storage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏽 This works fine now
src/index.js
Outdated
// getTasks(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Kindly remove all codes that are commented out. Removing such codes makes your code look clean.
src/index.js
Outdated
// getTasks(); | ||
console.log(tasks); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Kindly remove all codes that are commented out. Removing such codes makes your code look clean.
src/index.js
Outdated
// getTasks(); | ||
console.log(tasks); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Kindly remove all codes that are commented out. Removing such codes makes your code look clean.
- Kindly remove the
console.log
function in your code. It is a best practice to remove allconsole.log
statements from your code so that you do not reveal sensitive information to visitors of your site.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏽 This has been implemented also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @omar25ahmed
Your project is complete! There is nothing else to say other than... it's time to merge it
STATUS: APPROVED 🟢
Congratulations! 🎉
Cheers and Happy coding!👏👏👏
Feel free to leave any questions or comments in the PR thread if something is not 100% clear.
Please, remember to tag me @Whoistolu in your question so I can receive the notification.
As described in the Code reviews limits policy you have a limited number of reviews per project (check the exact number in your Dashboard). If you think that the code review was not fair, you can request a second opinion using this form.
Learning Objectives: