Skip to content

Commit

Permalink
check
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinaHranovska committed Feb 22, 2024
1 parent 017c317 commit 58b6136
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/js/add-to-favorites.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function getIdFavorites(cardID) {

refs.removeFromFavoritesBtn.addEventListener('click', () => removeIdFavorites(cardID));

function removeIdFavorites(cardID) {
export function removeIdFavorites(cardID) {
refs.removeFromFavoritesBtn.classList.add('hidden-btn');
refs.addToFavoritesBtn.classList.remove('hidden-btn');
updateGallery(cardID);
Expand Down Expand Up @@ -72,4 +72,4 @@ function updateGallery(cardID) {

function updateLicalStorage() {
return localStorage.getItem('addKeyID');
}
}
11 changes: 2 additions & 9 deletions src/js/favorities.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getAccess } from './helper/get-access.js';
import { iziToastFunctions } from './helper/helpers.js';
import icons from '../img/icons/sprite.svg';
import { removeIdFavorites } from './add-to-favorites.js';

const refs = {
favoritesCard: document.getElementById('favorites-container'),
Expand Down Expand Up @@ -29,7 +30,6 @@ function displayFavoriteCards(savedCards) {
smoothScrollToNextGroup();
}
checkContainerHeight();

}

refs.galleryWindow.addEventListener('click', deleteFavorites);
Expand All @@ -39,10 +39,9 @@ function deleteFavorites(e) {
const card = e.target.closest('.list-favorites-item');

card.classList.add('animation-items-remove'); // Додаємо клас для анімації видалення

setTimeout(() => {
const cardId = card.dataset.id;
removeFavoriteCard(cardId);
removeIdFavorites(cardId)
card.remove();

const savedCards = JSON.parse(localStorage.getItem('addKeyID')) || [];
Expand All @@ -53,12 +52,6 @@ function deleteFavorites(e) {
}
}

function removeFavoriteCard(id) {
let savedCards = JSON.parse(localStorage.getItem('addKeyID')) || [];
savedCards = savedCards.filter(card => card !== id);
localStorage.setItem('addKeyID', JSON.stringify(savedCards));
}

function showRemoveCards() {
refs.removeCards.classList.remove("is-hidden");
}
Expand Down

0 comments on commit 58b6136

Please sign in to comment.