Skip to content
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

friends-app #731

Merged
merged 7 commits into from
Nov 6, 2022
Merged

friends-app #731

merged 7 commits into from
Nov 6, 2022

Conversation

kirill8210
Copy link
Contributor

friends-app

Demo |
Code base

The code is submitted in a dedicated feature branch.

Only code files are submitted.

Please, review.

@OleksiyRudenko OleksiyRudenko added task-Friends 🕚 LDS Last Day Submission (Sep 29-30) labels Oct 1, 2022
@github-actions
Copy link

github-actions bot commented Oct 1, 2022

Hey!

Congratulations on your PR! 😎😎😎

Let's do some self-checks to fix most common issues and to make some improvements to the code before reviewers put their hands on the code.

Go through the requirements/most common mistakes linked below and fix the code as appropriate.

If you have any questions to requirements/common mistakes feel free asking them here or in Students' chat.

When you genuinely believe you are done put a comment stating that you have completed self-checks and fixed code accordingly.

Also, be aware, that if you would silently ignore this recommendation, a mentor can think that you are still working on fixes. And your PR will not be reviewed. 😒

Please, make sure you haven't made common mistakes.

In addition to the bot's suggestions above, please post a link to the app demo in Students' chat, collect feedback and fix bugs if any based on that. When user tests are done post here a comment on that.

Universal recommendations:

  • Make sure your code follows General Requirements
  • Use common sense or seek for an advice whenever requirements look ambiguous or unclear.
  • Pay more attention to code style - descriptive variable names, indentations, empty spaces, etc. Code should look good :)

By the way, you may proceed to the next task before this one is reviewed and merged.

Sincerely yours,
Submissions Kottachecker 😺

@yaripey yaripey self-assigned this Oct 2, 2022
Copy link

@yaripey yaripey left a comment

Choose a reason for hiding this comment

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

Hi! I would like to request some changes without looking at the code yet since you have some strange behaviors in your project. First of all, pressing all gender seems to reverse the array of displayed users for some reason. Secondly, if you write a name in the search and then click any of the gender options - it clears out the search input (which it should not do).

Also, please include your other code files, not only the JS one.

@kirill8210
Copy link
Contributor Author

Made edits. Also added other project files

Copy link

@yaripey yaripey left a comment

Choose a reason for hiding this comment

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

Hi, sorry for the long delay.

Nice work, but there's a lot to fix and improve here. I'm not going to do a very thorough review, rather guide your thinking to another path and we'll work it out from there. Please follow comments in the code.

Besides, found a couple of bugs/rough edges in your work, make sure to fix them too:

  1. You can only search by users' first names in your work. Last names should be included too.
  2. In mobile version, I believe you set your menu to hide every time users changes something. This isn't a good place for such behaviour because:
    1. This isn't a navigation menu where you would like to close it after, for example, navigating to another page. This is a complicated "settings"-like menu, where user possibly would like to change several inputs at once before turning to content.
    2. This behaviour introduced a bug, where the menu would close each time you type a button in the search input, what makes it practically unusable.

Also, please include all code files that you worked with, not only js. html and css could still contain some mistakes and potential room for improvements.

@@ -0,0 +1,8 @@
let URL_API = 'https://randomuser.me/api/?results=50&nat=us,gb,ua&inc=gender,name,email,dob,phone,picture';
Copy link

Choose a reason for hiding this comment

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

const?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

corrected

let data = [];
let response = [];

const createCard = (data2) => {
Copy link

Choose a reason for hiding this comment

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

To avoid numerating variable names like this you should give them more specific names. Data is cool and general, but barely helps you in development. What kind of data is it? Is it a user? Maybe several users? You should know what to expect from the data by the name here. And the global data on the 6th line is too general too. I can see it is an array, so it means users, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

corrected

let response = [];

const createCard = (data2) => {
const { name, gender, email, phone, picture, dob } = data2;
Copy link

Choose a reason for hiding this comment

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

You could've done this where the function get's it's arguments. Like this:

const createCard = ({ name, gender, ... }) => {

So no need in the data2 variable at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

corrected

Comment on lines 15 to 27
let phones = Number(phone.replace(/\D+/g,''));
if (phones.toString().length === 6) {
phones = '0000' + phones
} else if (phones.toString().length === 7) {
phones = '000' + phones
} else if (phones.toString().length === 8) {
phones = '00' + phones
} else if (phones.toString().length === 9) {
phones = '0' + phones
} else if (phones.toString().length === 11 || phones.toString().length === 12 || phones.toString().length === 13) {
phones = phones.toString().replace(phones.toString(), phones.toString().slice(-10))
}
let result = phones.toString().replace(/^(.{3})(.{3})(.{2})(.*)$/, "($1) $2-$3-$4");
Copy link

Choose a reason for hiding this comment

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

This seems very complicated and while I understand what is your goal here, it looks ugly here. Maybe just separate it to it's own function like, preparePhoneNumber or something like it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to a separate function

Comment on lines 47 to 56
const sortAge = document.querySelector('.sort_by_age');
const sortListAge = document.querySelector('.sorts_list_age');
const sortIdAge = document.querySelector('#sort_by_age');
const sortName = document.querySelector('.sort_by_name');
const sortListName = document.querySelector('.sorts_list_name');
const sortIdName = document.querySelector('#sort_by_name');
const filterIdGender = document.querySelector('#filters_gender');
const inputSearch = document.querySelector('#search_friends');
const reset = document.querySelector('.reset_button');
const inputAll = document.querySelector('#all');
Copy link

Choose a reason for hiding this comment

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

That's a lot of element picking. Remember that if you just wrap any inputs in a form, you can get this form with a query selector once and then access it's inputs' values any time you want, like with an object. Just remember to give them names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

did not understand what to do. move to a separate file, into a function and export the names of the constants?


let genders = Array.from(document.getElementsByName("gender")).find(r => r.checked).value;

sortAge.addEventListener('click', () => {
Copy link

Choose a reason for hiding this comment

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

You also have a lot of event listeners. Ideally you can do the whole thing with only 1 event listener. Just place it on the form, track the "input" event and work with data in the form every time the user changes something.


const sortByAge = () => {
if (inputSearch.value.length !== 0) {
const fByG = filterByGender()
Copy link

Choose a reason for hiding this comment

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

Use fuller names, no need to shorten so much.

Also, what is filterByGender() doing here? I believe current function name is sortByAge. Your function should follow the single responsobility principle. Sorting function should not invoke filtering function. It shouldn't do anything besides sorting at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

corrected

if (target.classList.contains('sorts_options')) {
sortName.textContent = target.textContent;
sortIdName.value = target.dataset.sort;
console.log(sortIdName.value);
Copy link

Choose a reason for hiding this comment

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

Don't leave console.logs in the finished code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

corrected

renderCards(data)
};

reset.addEventListener('click', e => {
Copy link

Choose a reason for hiding this comment

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

Google input type="reset"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

honored Google, applied

@kirill8210
Copy link
Contributor Author

fixed bugs and comments

@kirill8210
Copy link
Contributor Author

error correction

@yaripey yaripey merged commit 212264a into kottans:main Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕚 LDS Last Day Submission (Sep 29-30) Stage0.1 task-Friends
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants