Skip to content

Commit

Permalink
Merge pull request #14 from KristinaHranovska/pagination-mentor-changes
Browse files Browse the repository at this point in the history
Додано перевірку на кількість сторінок перед відображенням пагінації
  • Loading branch information
KristinaHranovska authored Feb 14, 2024
2 parents 900714c + 8cbf125 commit a24b2bc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
24 changes: 14 additions & 10 deletions src/js/body-parts.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,20 @@ function updateExercisesList(filter) {
'<p class="ex-list-no-result">Unfortunately, <span class="accent-text">no results</span> were found. You may want to consider other search options to find the exercise you are looking for. Our range is wide and you have the opportunity to find more options that suit your needs.</p>';
} else {
renderExercises(data.results);
document.querySelector('.tui-pagination').style.display = 'flex';
createPaginationExercisesInner(data.totalPages).on(
'afterMove',
({ page }) => {
loadExercises(filter, page).then(data => {
galleryElement.innerHTML = '';
renderExercises(data.results);
});
}
);
if (data.totalPages > 1) {
document.querySelector('.tui-pagination').style.display = 'flex';
createPaginationExercisesInner(data.totalPages).on(
'afterMove',
({ page }) => {
loadExercises(filter, page).then(data => {
galleryElement.innerHTML = '';
renderExercises(data.results);
});
}
);
} else {
document.querySelector('.tui-pagination').style.display = 'none';
}
}
getLoader('hide');
})
Expand Down
26 changes: 15 additions & 11 deletions src/js/muscles.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,21 @@ async function handleSearch() {
.then(data => {
const { results } = data;
createMarkup(results);
document.querySelector('.tui-pagination').style.display = 'flex';
createPaginationExercisesOuter(data.totalPages).on(
'afterMove',
({ page }) => {
getData(page).then(data => {
const { results } = data;
refs.gallery.innerHTML = '';
createMarkup(results);
});
}
);
if (data.totalPages > 1) {
document.querySelector('.tui-pagination').style.display = 'flex';
createPaginationExercisesOuter(data.totalPages).on(
'afterMove',
({ page }) => {
getData(page).then(data => {
const { results } = data;
refs.gallery.innerHTML = '';
createMarkup(results);
});
}
);
} else {
document.querySelector('.tui-pagination').style.display = 'none';
}
})
.catch(error => {
handleError(error.message);
Expand Down

0 comments on commit a24b2bc

Please sign in to comment.