добавлена работа со списками продуктов, попытка оптимизировать запрос по поиску коктейлей

This commit is contained in:
Kayashov.SM
2025-08-20 12:53:41 +04:00
parent 9809a19762
commit 34295bc045
15 changed files with 118 additions and 26 deletions

View File

@@ -41,9 +41,6 @@ export function PublicLayout({ children }) {
Добро пожаловать в бар
</Box>
</Typography>
<Typography align="center" variant="subtitle1">
Самый большой выбор честно спизженных коктейлей
</Typography>
<Box
component="img"
alt="Under development"

View File

@@ -2,7 +2,7 @@ import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import Toolbar from "@mui/material/Toolbar";
import Paper from "@mui/material/Paper";
import {Fab, FormControl, FormControlLabel, InputAdornment, InputLabel, OutlinedInput, Tabs} from "@mui/material";
import {Fab, FormControl, InputAdornment, InputLabel, OutlinedInput, Tabs} from "@mui/material";
import IconButton from "@mui/material/IconButton";
import SearchIcon from "@mui/icons-material/Search";
import * as React from "react";
@@ -18,7 +18,6 @@ import {CustomTabPanel} from "../../../components/core/TabPanel";
import {IngredientList} from "../../../components/Ingredients/IngredientList";
import {blue} from "@mui/material/colors";
import UpIcon from "@mui/icons-material/KeyboardArrowUp";
import Switch from "@mui/material/Switch";
import {useSelect} from "../../../hooks/useSelect";
export function IngredientsPage() {
@@ -28,7 +27,7 @@ export function IngredientsPage() {
const [findString, setFindString] = useState("");
const [ingredients, setIngredients] = useState([]);
const {getIngredient, selectIngredient} = useSelect();
const {createError} = useAlert();
const {createError, createSuccess} = useAlert();
useEffect(() => {
api().get(requests.bar.ingredientList)
@@ -77,6 +76,14 @@ export function IngredientsPage() {
const handleOpenModal = (i) => {
selectIngredient(i)
}
const handleDelete = (id) => {
const newState = ingredients.filter((ingredient) => ingredient.id !== id);
setIngredients(newState)
api().delete(`${requests.bar.ingredient}/${id}`)
.then((r) => createSuccess("Ингредиент удален"))
.catch(() => createError("Ошибка удаления ингредиента. Перезагрузите страницу"))
}
return (
<Box>
@@ -136,7 +143,7 @@ export function IngredientsPage() {
{/*Загрузчик*/}
<Loading loading={loading}/>
{/*Модальное окно информации об ингредиенте*/}
<IngredientInfoModal ingredient={getIngredient()}/>
<IngredientInfoModal ingredient={getIngredient()} handleDelete={handleDelete}/>
</Box>
)
}