Skip to content

Commit

Permalink
work in progress (fetch API) : index filtred by multiple tags (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
codexarama committed May 31, 2021
1 parent 2349d1a commit 5a2459b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions js/home_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,34 @@ function fetchData() {
console.log(tagsList);

// pour chaque tag du tableau
tagsList.forEach((tag) => {
tagsList.filter((tag) => {
// affiche photographe(s) dont tag(s) correspond(ent)
for (let j = 0; j < data.photographers.length; j++) {

// liste des tags de chaque photographe
console.log(data.photographers[j].tags);

// tag choisi = tag photographe
let selectedTags = data.photographers[j].tags.some(
const selectedTags = data.photographers[j].tags.some(
// let selectedTags = data.photographers[j].tags.map(
// let selectedTags = data.photographers[j].tags.filter(
(elmt) => elmt == tag
);

// tag choisi = tag photographe > true / false
console.log(selectedTags);
console.log(selectedTags == photographersTags[j]);

// si tag(s) choisi(s)
if (selectedTags) {
// affiche photographes correspondants
setPhotographers(data.photographers[j]);
}
}

// AFFICHE TOUS LES PHOTOGRAPHES SI AUCUN TAG N'EST CHOISI
// ----- NE FONCTIONNE PAS ----- //
// if (tagsList.length = 0) setPhotographers(data.photographers[j]);

});
});
}
Expand Down

0 comments on commit 5a2459b

Please sign in to comment.