Skip to content

Commit

Permalink
Refactor work.js to show edit bars and buttons if token is defined in…
Browse files Browse the repository at this point in the history
… local storage
  • Loading branch information
Gilles-Lucien committed Jan 4, 2024
1 parent ded232b commit e7dd947
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions FrontEnd/scripts/work.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ async function getWorks() {
}
}



// function to add a category button to the filters
function addCategory(category, filtersDiv) {
const buttonElement = document.createElement("button");
Expand Down Expand Up @@ -104,9 +102,20 @@ function handleFilterClick(event) {
});
}

getWorks();
getCategories();


// Check if token is defined in local storage
if (localStorage.getItem("token") !== null) {
// Toggle off the .hidden class for elements with .editBar class
const editBars = document.querySelectorAll(".editBar");
editBars.forEach((editBar) => {
editBar.classList.remove("hidden");
});

// Toggle off the .hidden class for elements with .editButton class
const editButtons = document.querySelectorAll(".editButton");
editButtons.forEach((editButton) => {
editButton.classList.remove("hidden");
});
}

getWorks();
getCategories();

0 comments on commit e7dd947

Please sign in to comment.