"Components/*": ["components/*"],
"Modals/*": ["components/modals/*"],
"Panels/*": ["components/panels/*"],
"Services/*": ["services/*"],
"Actions/*": ["actions/*"],
"Reducers/*": ["reducers/*"],
"Widgets/*": ["widgets/*"],
"Assets/*": ["assets/*"],
"Containers/*": ["containers/*"],
"Config/*": ["config/*"]
export const getDataMovie = (filmName) => {
const movieData = [];
async function getData(film) {
let resp = await fetch(`http://www.omdbapi.com/?t=${film}&apikey=...`);
resp = await resp.json();
const title = await resp.Title;
const year = await resp.Year;
const genre = await resp.Genre;
movieData.push({ title, year, genre });
}
return async (dispatch) => {
// делаем проверку на массив, потому что в компоненте favorite
// мы передаем массив названий фильмов
if (Array.isArray(filmName)) {
const result = filmName.map((item) => getData(item));
console.log(result);
await Promise.all(result);
dispatch(getFavoriteMovie(movieData));
} else {
getData(filmName);
dispatch(getFavoriteMovie(movieData));
}
};
};
<div class="NavItem_bar__38zjQ"></div>
.NavItem_item__3sDz .NavItem_bar__38zjQ {
border-top: 1px solid #00aeff;
margin: -7px 0 6px -1px;
width: 0;
const inputHobbies = document.querySelector(".page-info-wrap__hobbies-input");
const btnAddHobbies = document.querySelector(".page-info-wrap__add-hobbies");
const ul = document.querySelector(".page-info-wrap__hobbies-list");
let listValues = [];
if (localStorage.getItem("myHobbies")) {
listValues = JSON.parse(localStorage.getItem("myHobbies"));
}
for (let i = 0; i <= listValues.length-1; i++) {
let newLi = document.createElement('li');
ul.appendChild(newLi);
newLi.textContent = listValues[i];
}
btnAddHobbies.addEventListener("click", () => {
let newLi = document.createElement('li');
const input = inputHobbies.value;
if (input) {
// убрать манипулирование стилями
newLi.textContent = input;
ul.appendChild(newLi);
// добавляю значения в массив, чтобы потом кинуть в локалстор
listValues.push(newLi.textContent);
inputHobbies.value = "";
localStorage.setItem("myHobbies", JSON.stringify(listValues));
if (listValues.length >= 5) {
btnAddHobbies.setAttribute('disabled', 'disabled');
}
}
});
ul.addEventListener('click', function(event) {
const target = event.target;
if (target.tagName === "LI") {
target.remove();
listValues.pop(target);
localStorage.setItem("myHobbies", JSON.stringify(listValues));
}
});