Skip to content

Commit

Permalink
bug fix and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
konstantin-it-lysenko committed Oct 16, 2023
1 parent e0d1e80 commit 7715c41
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ async function submitBtnHandler(event) {
try {
const queryData = await getQueryData(searchQuery, page);

form.reset();
if (queryData.hits.length === 0) {
return failureResponse();
};
if (queryData.hits.length > 0) {
Notiflix.Notify.success(`You have received ${queryData.totalHits} images`, {
distance: '90px',
position: "center-top"
})
}

refs.galleryEl.innerHTML = createGalleryMarkup(queryData.hits);

if (queryData.hits.length === 0) {
failureResponse();
};
if (queryData.hits.length < 40) {
refs.loadMoreBtn.classList.add('is-hidden');
} else {
refs.loadMoreBtn.classList.remove('is-hidden');
};
} catch { failureResponse() }

form.reset();
refs.galleryEl.innerHTML = createGalleryMarkup(queryData.hits);
let gallery = new SimpleLightbox('.gallery a');

} catch { failureResponse() }

let gallery = new SimpleLightbox('.gallery a');
}

async function loadMoreBtnHandler() {
Expand Down

0 comments on commit 7715c41

Please sign in to comment.