Исправление ошибки отображения фотографий (front)

This commit is contained in:
Administrator
2025-04-26 06:27:05 +00:00
parent dce8d4b0b7
commit fdb8bc43d1
7 changed files with 27 additions and 70 deletions

View File

@@ -14,59 +14,9 @@ import {useUser} from "../../../hooks/useUser";
import {blue} from "@mui/material/colors";
import UpIcon from "@mui/icons-material/KeyboardArrowUp";
import {sortList} from "../../../components/cocktails/sortingList";
import {getComparator} from "../../../components/core/getComparator";
import Button from "@mui/material/Button";
import Paper from "@mui/material/Paper";
import CheckMarks from "../../../components/cocktails/CheckMarks";
import {useSelect} from "../../../hooks/useSelect";
const filterList = (rows, filter, allowIngredients) => {
let regExp = new RegExp("(.*?)" + filter.search + "(.*?)", "i");
const sortingObj = sortList.find((s) => s.name === filter.sorting);
const sortingValues = sortingObj.id.split("|");
return rows
.filter((row) => {
const nameReg = row.name.split(" ").map((n) => n.match(regExp) !== null).includes(true);
const ingredientReg = row.components
.split(", ")
.map((r) => r.match(regExp) !== null)
.includes(true);
return nameReg || ingredientReg;
})
.filter((row) => filter.onlyFavourite ? row.rating.favourite : true)
.filter((row) => filter.glass.length === 0 || filter.glass.includes(row.glass))
.filter((row) => filter.category.length === 0 || filter.category.includes(row.category))
.filter((row) => filter.alcohol.length === 0 || filter.alcohol.includes(row.alcoholic))
.filter((row) => {
if (filter.tags.length === 0) {
return true;
}
if (row.tags.length === 0) {
return false;
}
return row.tags.split(",").find((tag) => filter.tags.includes(tag))
})
.filter((row) => {
if (filter.iCount.length === 0) {
return true;
}
const arr = row.components.split(", ");
const count = arr.filter((n) => !allowIngredients.includes(n)).length;
const filt = filter.ingredient.length === 0 || arr.filter((n) => filter.ingredient.includes(n)).length > 0;
return filter.iCount === count && filt;
})
.filter((row) => {
if (filter.inMenu === "") {
return row;
}
const filterValue = filter.inMenu === "Есть в меню";
return filterValue === row.inMenu;
})
.sort(getComparator(sortingValues[1], sortingValues[0], "name"))
}
const emptyFilter = {
search: "",
hidden: true,
@@ -87,7 +37,7 @@ const CocktailsPageContent = ({all}) => {
const [allowIngredients, setAllowIngredients] = useState([])
const [rows, setRows] = useState([]);
const [filter, setFilter] = useState(emptyFilter)
const [chips, setChips] = useState([])
// const [chips, setChips] = useState([])
const [page, setPage] = useState(-1);
const [load, setLoad] = useState(false);
const [isEnd, setIsEnd] = useState(false);
@@ -112,7 +62,7 @@ const CocktailsPageContent = ({all}) => {
api().post(requests.cocktails.menu, request)
.then((r) => {
if (r.data.length === 0) {
if(isNew) {
if (isNew) {
setRows([]);
}
setIsEnd(true);
@@ -140,6 +90,7 @@ const CocktailsPageContent = ({all}) => {
}
window.addEventListener('scroll', handleScroll);
return () => window.removeEventListener('scroll', handleScroll);
// eslint-disable-next-line
}, [loading]);
useEffect(() => {
api().get(requests.bar.ingredientSimple)
@@ -153,6 +104,7 @@ const CocktailsPageContent = ({all}) => {
}, [])
useEffect(() => {
loading();
// eslint-disable-next-line
}, [filter])
useEffect(() => {
if (!all) {
@@ -165,7 +117,8 @@ const CocktailsPageContent = ({all}) => {
.filter((nhc) => nhc.length === 1)
.map((fc) => fc[0])
.forEach((i) => ingredients.add(i))
setChips(Array.from(ingredients).sort(getComparator()));
// setChips(Array.from(ingredients).sort(getComparator()));
// eslint-disable-next-line
}, [rows, allowIngredients])
const renderSkeleton = () => {