diff --git a/src/assets/js/login.js b/src/assets/js/login.js index a5270f0..942eab7 100644 --- a/src/assets/js/login.js +++ b/src/assets/js/login.js @@ -72,7 +72,8 @@ function register(event) { name: name, username: username, email: email, - password: password + password: password, + components: [] } try { diff --git a/src/projetos/assets/js/app.js b/src/projetos/assets/js/app.js index 52bc0f4..4082997 100644 --- a/src/projetos/assets/js/app.js +++ b/src/projetos/assets/js/app.js @@ -46,7 +46,9 @@ async function ShowProjects() { try { await LoadProjects(); - const textoHTML = projectsList.map(generateHTML).join(''); + const filteredProjectsList = filter(); + + const textoHTML = filteredProjectsList.map(generateHTML).join(''); document.querySelector("#projects").innerHTML = textoHTML; @@ -184,18 +186,18 @@ async function deleteProject() { // SEARCH -document.querySelector('.search-bar').addEventListener('input', search, false); +document.querySelector('.search-bar').addEventListener('input', ShowProjects, false); function normalizeString(str) { return str.toLowerCase().normalize('NFD').replace(/\p{Diacritic}/gu, ''); } -function search() { +function filter() { const query = normalizeString(document.querySelector('.search-bar #search').value); const difficulty = document.querySelector('#difficulty').value; - const filteredProjects = projectsList.filter(project => { + return projectsList.filter(project => { const { dificuldade, titulo, categoria, conteudo, autor } = project; return normalizeString(dificuldade).includes(difficulty) && ( normalizeString(titulo).includes(query) || @@ -204,8 +206,4 @@ function search() { normalizeString(autor).includes(query) ) }); - - const textoHTML = filteredProjects.map(generateHTML).join(''); - - document.querySelector("#projects").innerHTML = textoHTML; }