Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
TetiZ committed Feb 1, 2024
2 parents 8c200b4 + dee5cbf commit db011e5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 25 deletions.
5 changes: 0 additions & 5 deletions src/js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export async function bodyPart(event) {
searchInput = encodeURIComponent(event.toLowerCase());

localStorage.setItem('searchInput', JSON.stringify({ searchInput }));

console.log(searchInput);

const url = `https://energyflow.b.goit.study/api/exercises?bodypart=${searchInput}&page=${currentPage}&limit=${limit}`;
const response = await fetch(url);
Expand All @@ -53,7 +51,6 @@ export async function bodyPart(event) {
const resultPromise = response.json();
const results = await resultPromise;

console.log(results);

if (results.length === 0) {
throw new Error('No data found. Please try a different search term.');
Expand Down Expand Up @@ -88,8 +85,6 @@ export async function equipment(event) {
const resultPromise = response.json();
const results = await resultPromise;

console.log(results);

if (results.length === 0) {
throw new Error('No data found. Please try a different search term.');
}
Expand Down
18 changes: 5 additions & 13 deletions src/js/exersises.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ exerciseList.addEventListener('click', async event => {
`,
''
);
} catch (error) {
console.error('Error:', error);
}
} catch (error) {}
});

pageCounter.addEventListener('click', async event => {
Expand Down Expand Up @@ -246,9 +244,7 @@ pageCounter.addEventListener('click', async event => {
`,
''
);
} catch (error) {
console.error('Error:', error);
}
} catch (error) {}
});

exercise.forEach(elem => {
Expand Down Expand Up @@ -377,9 +373,7 @@ exerciseForm.addEventListener('submit', async function (event) {
''
);
}
} catch (error) {
console.error('Error:', error);
}
} catch (error) {}
});

pageCounter.addEventListener('click', async event => {
Expand Down Expand Up @@ -468,9 +462,7 @@ pageCounter.addEventListener('click', async event => {
`,
''
);
} catch (error) {
console.error('Error:', error);
}
} catch (error) {}
});

const modal = document.querySelector('.modal123');
Expand Down Expand Up @@ -609,7 +601,6 @@ function dataToStorage(data) {
if (popAddFavButton) {
popAddFavButton.addEventListener('click', clickHandler);
} else {
console.error('Button not found');
}

// Close card foo's
Expand Down Expand Up @@ -659,6 +650,7 @@ const pagesCounter = document.querySelector('.fav-counter');
const emptyContainer = document.querySelector('.empty-content-fav');

function renderCardsFromStorage(e) {
const savedCards = JSON.parse(localStorage.getItem('exercises'));
if (savedCards.length != 0) {
emptyContainer.classList.add('visually-hidden');
}
Expand Down
1 change: 1 addition & 0 deletions src/js/page-after-switch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const currentPath = window.location.pathname;

const homePage = document.querySelector('#Home');
const favoritesPage = document.querySelector('#Favorites');
const homePageMenu = document.querySelector('#Home-menu');
Expand Down
3 changes: 0 additions & 3 deletions src/js/quote.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const currentDate = new Date().toDateString();
if (storedDate === currentDate) {
const storedQuote = localStorage.getItem(QUOTE_KEY);
const storedAuthor = localStorage.getItem(AUTHOR_KEY);
console.log(`Збережена цитата: ${storedQuote} - ${storedAuthor}`);
displayQuote({ quote: storedQuote, author: storedAuthor });
} else {
async function fetchData() {
Expand All @@ -22,8 +21,6 @@ if (storedDate === currentDate) {
localStorage.setItem(AUTHOR_KEY, author || 'автор невідомий');
localStorage.setItem('date', currentDate);

console.log(`Нова цитата: ${quote} - ${author || 'автор невідомий'}`);

displayQuote({ quote, author: author || 'автор невідомий' });
} else {
throw new Error('Помилка запиту до сервера!');
Expand Down
14 changes: 10 additions & 4 deletions src/js/submit-email-footer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const form = document.querySelector('.subs-form');
const localStorageKey = 'user-email';
const savedEmail = localStorage.getItem(localStorageKey);

form.elements.email.value = savedEmail ? savedEmail : '';
form.addEventListener('input', saveToLocalStorage);
function saveToLocalStorage(evt) {
Expand All @@ -19,14 +20,19 @@ async function postEmail(userEmail) {
}
);
if (!response.ok) {
console.error('Код помилки:', response.status);
throw new Error('Мережевий запит не був успішним');
}
const data = await response.json();

iziToast.success({
title: 'We are excited to have you on board!',
message:
'Thank you for subscribing to new exercises on Energy Flow. You have just taken a significant step towards improving your fitness and well-being.',
position: 'center',
});

console.log('Дані успішно відправлені', data);
} catch (error) {
console.error('Помилка при відправленні даних', error);
}
} catch (error) {}
}
form.addEventListener('submit', async e => {
e.preventDefault();
Expand Down

0 comments on commit db011e5

Please sign in to comment.