diff --git a/src/scripts.js b/src/scripts.js index eb98ca58b..7ec092eda 100644 --- a/src/scripts.js +++ b/src/scripts.js @@ -39,8 +39,15 @@ function fetchData() { document.getElementById('date-selector').innerHTML += `` }) + const justUsers = userData.users.reduce((acc, user) => { + acc.push({[user.id]: user.name}) + return acc + }, []) + + console.log(justUsers) + updateDom(appState.randomUser, appState.account.user); - // generateUserList(justUsers) + generateUserList(justUsers) }) .catch(error => console.error("Error loading data:", error)); } @@ -350,10 +357,14 @@ function handleDrop(event) { } function generateUserList(users) { - console.log(users) - let userList = users.sort() + const userList = users.sort((a, b) => { + const nameA = Object.values(a)[0]; + const nameB = Object.values(b)[0]; + return nameA.localeCompare(nameB); + }); userList.forEach((user) => { - userSelect.innerHTML += `` + console.log(Object.values(user)[0]) + userSelect.innerHTML += `` }) fuzzySearch.innerHTML = userSelect.innerHTML let filterInput = document.querySelector(".filter-field")