-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1a3d69
commit a3db4e7
Showing
6 changed files
with
18 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import imageRetina from '../img/[email protected]'; | |
const apiService = new APIService(); | ||
|
||
let isFavorite = false; | ||
let idFavorite; | ||
|
||
const modalExercises = document.querySelector('.modal-exercises'); | ||
const overlay = document.querySelector('.overlay'); | ||
|
@@ -24,6 +25,8 @@ async function onExercisesCardClick(event) { | |
|
||
const exerciseData = await apiService.getExercisesById(exerciseID); | ||
|
||
idFavorite = exerciseID; | ||
|
||
const markup = createMarkup(exerciseData); | ||
updateModal(markup); | ||
openModalExercises(); | ||
|
@@ -186,11 +189,18 @@ function createMarkup({ | |
} | ||
|
||
function toggleFavorites() { | ||
isFavorite = !isFavorite; | ||
// isFavorite = !isFavorite; | ||
|
||
const local = JSON.parse(localStorage.getItem('exerciseData')); | ||
|
||
if (local?.some(item => item._id === idFavorite)) { | ||
isFavorite = true; | ||
} | ||
|
||
const btnModalFavorites = document.querySelector( | ||
'.modal-exercises__btn-favorites' | ||
); | ||
|
||
const favoritesIcon = document.querySelector('.btn-favorites__icon'); | ||
|
||
if (isFavorite) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters