удалены основные сущности фронт
This commit is contained in:
@@ -5,18 +5,12 @@ import NotFoundPage from "./pages/notFound/NotFoundPage";
|
||||
import {UserLayout} from "./layout/UserLayout";
|
||||
import {HomeRedirect} from "./HomeRedirect";
|
||||
import {PublicLayout} from "./layout/PublicLayout";
|
||||
import QueuePage from "./pages/queue/QueuePage";
|
||||
import LoginPage from "./pages/auth/sign-in/loginPage";
|
||||
import {TelegramCode} from "./pages/auth/sign-in/telegram-code";
|
||||
import {IngredientsPage} from "./pages/ingredients/IngredientsPage";
|
||||
import {MenuPage} from "./pages/cocktails/MenuPage";
|
||||
import {AllCocktailsPage} from "./pages/cocktails/AllCocktailsPage";
|
||||
import {EditIngredientPage} from "./pages/ingredients/EditIngredientPage";
|
||||
import {EditCocktailPage} from "./pages/cocktails/EditCocktailPage";
|
||||
import {MyQueuePage} from "./pages/queue/MyQueuePage";
|
||||
import {VisitorPage} from "./pages/VisitorPage";
|
||||
import {CocktailMenuBarPage} from "./pages/cocktails/CocktailMenuBarPage";
|
||||
import {MyBarPage} from "./pages/MyBarPage";
|
||||
import {useEffect, useState} from "react";
|
||||
|
||||
export function NavigationRoutes() {
|
||||
@@ -70,47 +64,17 @@ const authPages = [
|
||||
children: (<MenuPage/>),
|
||||
exact: true,
|
||||
},
|
||||
{
|
||||
path: paths.bar.cocktails,
|
||||
isPrivate: true,
|
||||
children: (<AllCocktailsPage/>)
|
||||
},
|
||||
{
|
||||
path: paths.bar.list,
|
||||
isPrivate: true,
|
||||
children: (<MyBarPage/>)
|
||||
},
|
||||
{
|
||||
path: paths.orders.my,
|
||||
isPrivate: true,
|
||||
children: (<MyQueuePage/>)
|
||||
},
|
||||
{
|
||||
path: paths.bar.ingredients,
|
||||
isPrivate: true,
|
||||
children: (<IngredientsPage/>)
|
||||
},
|
||||
{
|
||||
path: paths.bar.ordersQueue,
|
||||
isPrivate: true,
|
||||
children: (<QueuePage/>),
|
||||
},
|
||||
{
|
||||
path: paths.visitor.inBar,
|
||||
isPrivate: true,
|
||||
children: (<VisitorPage/>)
|
||||
},
|
||||
{
|
||||
path: paths.bar.ingredientEdit,
|
||||
isPrivate: true,
|
||||
forAdmin: true,
|
||||
children: (<EditIngredientPage/>)
|
||||
},
|
||||
{
|
||||
path: paths.bar.menu,
|
||||
isPrivate: true,
|
||||
children: (<CocktailMenuBarPage/>)
|
||||
},
|
||||
{
|
||||
path: paths.bar.cocktailEdit,
|
||||
isPrivate: true,
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
import Box from "@mui/material/Box";
|
||||
import Toolbar from "@mui/material/Toolbar";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import Paper from "@mui/material/Paper";
|
||||
import {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";
|
||||
import {useState} from "react";
|
||||
import Tab from "@mui/material/Tab";
|
||||
import {a11yProps} from "../../components/core/tabProps";
|
||||
import {CustomTabPanel} from "../../components/core/TabPanel";
|
||||
import {BarList} from "../../components/bar/BarList";
|
||||
|
||||
export function MyBarPage() {
|
||||
const [value, setValue] = React.useState(0);
|
||||
const handleChange = (event, newValue) => setValue(newValue);
|
||||
const [findString, setFindString] = useState("");
|
||||
|
||||
return (
|
||||
<Box>
|
||||
{/*Заголовок*/}
|
||||
<Toolbar>
|
||||
<Typography variant="h6" component="div" sx={{flexGrow: 1}}>Мои бары</Typography>
|
||||
</Toolbar>
|
||||
{/*Поиск*/}
|
||||
<Paper elevation={6} sx={{my: 2}}>
|
||||
<FormControl sx={{m: 1, width: 'calc(100% - 20px'}}>
|
||||
<InputLabel htmlFor="outlined-adornment-amount">Поиск</InputLabel>
|
||||
<OutlinedInput
|
||||
onChange={(e) => setFindString(e.target.value)}
|
||||
label="With normal TextField"
|
||||
startAdornment={
|
||||
<InputAdornment position="start">
|
||||
<IconButton edge="end">
|
||||
<SearchIcon/>
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
</Paper>
|
||||
{/*Рабочее поле ингредиентов*/}
|
||||
<Box>
|
||||
<Tabs value={value} onChange={handleChange} aria-label="basic tabs example">
|
||||
<Tab label="Мои бары" {...a11yProps(0)} />
|
||||
<Tab label="Список" {...a11yProps(1)} />
|
||||
</Tabs>
|
||||
</Box>
|
||||
<Box>
|
||||
<CustomTabPanel value={value} index={0}>
|
||||
<BarList all={false} find={findString}/>
|
||||
</CustomTabPanel>
|
||||
<CustomTabPanel value={value} index={1}>
|
||||
<BarList all={true} find={findString}/>
|
||||
</CustomTabPanel>
|
||||
</Box>
|
||||
{/*Модальное окно информации об ингредиенте*/}
|
||||
{/*<IngredientInfoModal ingredient={selectedInfo} open={openModal} closeHandler={handleCloseModal}/>*/}
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
import Box from "@mui/material/Box";
|
||||
import {useEffect, useState} from "react";
|
||||
import {api} from "../../lib/clients/api";
|
||||
import {requests} from "../../requests";
|
||||
import {useAlert} from "../../hooks/useAlert";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import {VisitorItem} from "../../components/visitor/VisitorItem";
|
||||
import Toolbar from "@mui/material/Toolbar";
|
||||
import * as React from "react";
|
||||
import Button from "@mui/material/Button";
|
||||
import {useUser} from "../../hooks/useUser";
|
||||
|
||||
export function VisitorPage() {
|
||||
const {session, checkSession} = useUser();
|
||||
const [visitors, setVisitors] = useState([])
|
||||
const [open, setOpen] = useState(false);
|
||||
const {createError} = useAlert();
|
||||
|
||||
useEffect(() => {
|
||||
api().get(requests.visitors.all)
|
||||
.then((r) => {
|
||||
setVisitors(r.data)
|
||||
})
|
||||
.catch(() => createError("Ошибка получения данных"))
|
||||
// eslint-disable-next-line
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
setOpen(session.isActive);
|
||||
}, [session, checkSession])
|
||||
|
||||
const changeHandler = (visitor) => {
|
||||
const arr = visitors.map((v) => {
|
||||
if(v.id === visitor.id) {
|
||||
return {
|
||||
...visitor,
|
||||
invited: !visitor.invited
|
||||
}
|
||||
}
|
||||
return v;
|
||||
})
|
||||
api().post(`${requests.visitors.invite}id=${visitor.id}&value=${!visitor.invited}`)
|
||||
.then(() => setVisitors(arr))
|
||||
.catch(() => createError("Ошибка запроса"))
|
||||
|
||||
}
|
||||
const changeShift = () => {
|
||||
api().post(`${requests.bar.session.change}?value=${!open}`)
|
||||
.then(() => {
|
||||
checkSession?.();
|
||||
setOpen(!open)
|
||||
})
|
||||
.catch(() => createError("Ошибка закрытия сессии"))
|
||||
}
|
||||
|
||||
return (
|
||||
<Box>
|
||||
{/*Заголовок*/}
|
||||
<Toolbar>
|
||||
<Typography variant="h6" component="div" sx={{flexGrow: 1}}>Посетители</Typography>
|
||||
</Toolbar>
|
||||
<Box ml={0} mb={2}>
|
||||
{visitors.map((v) => {
|
||||
return (
|
||||
<VisitorItem key={v.id} visitor={v} changeHandler={changeHandler} open={open}/>
|
||||
)
|
||||
})}
|
||||
</Box>
|
||||
|
||||
<Button
|
||||
variant='contained'
|
||||
color={open ? 'error' : 'success'}
|
||||
onClick={() => changeShift()}
|
||||
>{`${open ? "Закрыть " : "Открыть "}смену`}</Button>
|
||||
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import CocktailsPageContent from "./CocktailsPageContent";
|
||||
|
||||
export function AllCocktailsPage() {
|
||||
return (
|
||||
<CocktailsPageContent all={true}/>
|
||||
)
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
import Box from "@mui/material/Box";
|
||||
import Toolbar from "@mui/material/Toolbar";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import Paper from "@mui/material/Paper";
|
||||
import {Fab, FormControl, FormControlLabel, InputAdornment, InputLabel, OutlinedInput} from "@mui/material";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import SearchIcon from "@mui/icons-material/Search";
|
||||
import Switch from "@mui/material/Switch";
|
||||
import {blue} from "@mui/material/colors";
|
||||
import UpIcon from "@mui/icons-material/KeyboardArrowUp";
|
||||
import {Loading} from "../../../components/core/Loading";
|
||||
import * as React from "react";
|
||||
import {useEffect, useMemo, useState} from "react";
|
||||
import {CocktailsList} from "../../../components/cocktails/CocktailsList";
|
||||
import {requests} from "../../../requests";
|
||||
import {api} from "../../../lib/clients/api";
|
||||
import {useAlert} from "../../../hooks/useAlert";
|
||||
import {CocktailInfoModal} from "../../../components/cocktails/CocktailInfoModal";
|
||||
import {useSelect} from "../../../hooks/useSelect";
|
||||
|
||||
export function CocktailMenuBarPage() {
|
||||
const {createError} = useAlert();
|
||||
const [grouping, setGrouping] = useState(true);
|
||||
const [findString, setFindString] = useState("");
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [cocktails, setCocktails] = useState([]);
|
||||
const {setCocktail, state} = useSelect();
|
||||
|
||||
useEffect(() => {
|
||||
api().get(`${requests.cocktails.menu}?all=true`)
|
||||
.then((r) => {
|
||||
setCocktails(r.data);
|
||||
setLoading(false);
|
||||
})
|
||||
.catch(() => createError("Ошибка получения данных"))
|
||||
// eslint-disable-next-line
|
||||
}, []);
|
||||
|
||||
|
||||
const handleOpenModal = (row) => {
|
||||
setCocktail(row);
|
||||
}
|
||||
const changeHandler = (row, value) => {
|
||||
const newState = cocktails.map((r) => {
|
||||
if (r.id !== row.id) {
|
||||
return r;
|
||||
}
|
||||
return {
|
||||
...r,
|
||||
inMenu: value
|
||||
}
|
||||
});
|
||||
api().post(`${requests.cocktails.menu}?id=${row.id}&value=${value}`)
|
||||
.then(() => {
|
||||
setCocktails(newState);
|
||||
}).catch(() => createError("Ошибка сохранения данных"))
|
||||
}
|
||||
|
||||
const visibleRows = useMemo(() => {
|
||||
if (findString === "") {
|
||||
return cocktails;
|
||||
}
|
||||
let regExp = new RegExp("(.*?)" + findString + "(.*?)", "i");
|
||||
return cocktails
|
||||
.filter((row) => row.name.split(" ").map((n) => n.match(regExp) !== null).includes(true))
|
||||
// eslint-disable-next-line
|
||||
}, [cocktails, findString])
|
||||
|
||||
return (
|
||||
<Box>
|
||||
{/*Заголовок*/}
|
||||
<Toolbar>
|
||||
<Typography variant="h6" component="div" sx={{flexGrow: 1}}>Меню бара</Typography>
|
||||
</Toolbar>
|
||||
{/*Поиск*/}
|
||||
<Paper elevation={6} sx={{my: 2}}>
|
||||
<FormControl sx={{m: 1, width: 'calc(100% - 20px'}}>
|
||||
<InputLabel htmlFor="outlined-adornment-amount">Поиск</InputLabel>
|
||||
<OutlinedInput
|
||||
onChange={(e) => setFindString(e.target.value)}
|
||||
label="With normal TextField"
|
||||
startAdornment={
|
||||
<InputAdornment position="start">
|
||||
<IconButton edge="end">
|
||||
<SearchIcon/>
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControlLabel sx={{ml: '2px'}}
|
||||
control={<Switch defaultChecked/>}
|
||||
onClick={() => setGrouping(!grouping)}
|
||||
label="Группировать"
|
||||
labelPlacement="end"/>
|
||||
</Paper>
|
||||
{/*Рабочее поле коктейлей*/}
|
||||
<CocktailsList rows={visibleRows} changeHandler={changeHandler}
|
||||
infoHandler={handleOpenModal} grouping={grouping}/>
|
||||
{/*Иконка возврата наверх*/}
|
||||
<Fab sx={{
|
||||
alpha: '30%',
|
||||
position: 'sticky',
|
||||
bottom: '16px',
|
||||
color: 'common.white',
|
||||
bgcolor: blue[600],
|
||||
'&:hover': {
|
||||
bgcolor: blue[600],
|
||||
},
|
||||
}}
|
||||
onClick={() => window.window.scrollTo(0, 0)}
|
||||
aria-label='Expand'
|
||||
color='inherit'>
|
||||
<UpIcon/>
|
||||
</Fab>
|
||||
{/*Загрузчик*/}
|
||||
<Loading loading={loading}/>
|
||||
{/*Модальное окно информации об ингредиенте*/}
|
||||
<CocktailInfoModal row={state.cocktail}/>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import {getComparator} from "../../../components/core/getComparator";
|
||||
|
||||
const emptyFilter = {
|
||||
search: "",
|
||||
all: false,
|
||||
hidden: true,
|
||||
onlyFavourite: false,
|
||||
glass: [],
|
||||
@@ -34,7 +35,7 @@ const emptyFilter = {
|
||||
sorting: "Название по возрастанию"
|
||||
}
|
||||
|
||||
const CocktailsPageContent = ({all}) => {
|
||||
const CocktailsPageContent = () => {
|
||||
const {user} = useUser();
|
||||
const {createError, createSuccess} = useAlert();
|
||||
const [allowIngredients, setAllowIngredients] = useState([])
|
||||
@@ -56,7 +57,6 @@ const CocktailsPageContent = ({all}) => {
|
||||
setLoad(true);
|
||||
const request = {
|
||||
...filter,
|
||||
all: all,
|
||||
sort: sortList.find((s) => s.name === filter.sorting).id,
|
||||
page: page + 1,
|
||||
size: size,
|
||||
@@ -110,7 +110,7 @@ const CocktailsPageContent = ({all}) => {
|
||||
// eslint-disable-next-line
|
||||
}, [filter])
|
||||
useEffect(() => {
|
||||
if (!all) {
|
||||
if (!filter.all) {
|
||||
return;
|
||||
}
|
||||
const ingredients = new Set();
|
||||
@@ -197,7 +197,7 @@ const CocktailsPageContent = ({all}) => {
|
||||
if (r.id !== row.id) {
|
||||
return r;
|
||||
}
|
||||
if (all) {
|
||||
if (filter.all) {
|
||||
return {
|
||||
...r,
|
||||
inMenu: value
|
||||
@@ -233,12 +233,10 @@ const CocktailsPageContent = ({all}) => {
|
||||
handleFilterChange={handleFilterChange}
|
||||
handleClearFilter={handleFilterClear}
|
||||
barmen={user.role !== 'USER'}
|
||||
all={all}
|
||||
/>
|
||||
|
||||
{/*todo: доделать фильтр по количеству недостающих ингредиентов*/}
|
||||
{
|
||||
(all && filter.iCount === 1) && (
|
||||
(filter.all && filter.iCount === 1) && (
|
||||
<Paper sx={{mt: 1}}>
|
||||
<CheckMarks rows={chips} name={"Выбор ингредиента"} filterName={"ingredient"}
|
||||
filterValue={filter.ingredient}
|
||||
|
||||
@@ -2,6 +2,6 @@ import CocktailsPageContent from "./CocktailsPageContent";
|
||||
|
||||
export function MenuPage() {
|
||||
return (
|
||||
<CocktailsPageContent all={false}/>
|
||||
<CocktailsPageContent/>
|
||||
)
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import {useSelect} from "../../../hooks/useSelect";
|
||||
|
||||
export function IngredientsPage() {
|
||||
const [value, setValue] = React.useState(0);
|
||||
const [grouping, setGrouping] = useState(true);
|
||||
const handleChange = (event, newValue) => setValue(newValue);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [findString, setFindString] = useState("");
|
||||
@@ -101,11 +100,6 @@ export function IngredientsPage() {
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControlLabel sx={{ml: '2px'}}
|
||||
control={<Switch defaultChecked/>}
|
||||
onClick={() => setGrouping(!grouping)}
|
||||
label="Группировать"
|
||||
labelPlacement="end"/>
|
||||
</Paper>
|
||||
{/*Рабочее поле ингредиентов*/}
|
||||
<Box>
|
||||
@@ -117,11 +111,11 @@ export function IngredientsPage() {
|
||||
<Box>
|
||||
<CustomTabPanel value={value} index={0}>
|
||||
<IngredientList rows={ingredientsInBar} value={false} changeHandler={changeHandler}
|
||||
infoHandler={handleOpenModal} grouping={grouping}/>
|
||||
infoHandler={handleOpenModal}/>
|
||||
</CustomTabPanel>
|
||||
<CustomTabPanel value={value} index={1}>
|
||||
<IngredientList rows={ingredientsToAdd} value={true} changeHandler={changeHandler}
|
||||
infoHandler={handleOpenModal} grouping={grouping}/>
|
||||
infoHandler={handleOpenModal}/>
|
||||
</CustomTabPanel>
|
||||
</Box>
|
||||
<Fab sx={{
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import {QueueContent} from "./QueueContent";
|
||||
|
||||
export function MyQueuePage() {
|
||||
return (
|
||||
<QueueContent my={true}/>
|
||||
)
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
import {useEffect, useMemo, useState} from "react";
|
||||
import {useAlert} from "../../../hooks/useAlert";
|
||||
import * as React from "react";
|
||||
import {api} from "../../../lib/clients/api";
|
||||
import {requests} from "../../../requests";
|
||||
import {createHeadCell} from "../../../components/orders/createHeadCelll";
|
||||
import {Loading} from "../../../components/core/Loading";
|
||||
import OrderModal from "../../../components/orders/OrderModal";
|
||||
import EnhancedTable from "../../../components/orders/EnhancedTable";
|
||||
|
||||
export function QueueContent({my}) {
|
||||
const [load, setLoad] = useState(false);
|
||||
const [orders, setOrders] = useState([]);
|
||||
const {createSuccess, createError} = useAlert();
|
||||
const [openModal, setOpenModal] = React.useState(false);
|
||||
const [selected, setSelected] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
setLoad(false);
|
||||
const url = my ? requests.bar.myOrders : requests.bar.order;
|
||||
api().get(url)
|
||||
.then(r => {
|
||||
setOrders(r.data);
|
||||
setLoad(true);
|
||||
})
|
||||
.catch(() => {
|
||||
createError("Ошибка при получении заказов");
|
||||
setLoad(true)
|
||||
})
|
||||
// eslint-disable-next-line
|
||||
}, []);
|
||||
|
||||
const sliced = useMemo(() => orders.sort((a, b) => b.id - a.id), [orders])
|
||||
|
||||
const cells = [
|
||||
createHeadCell('id', true, true, 'Номер заказа', "20px"),
|
||||
createHeadCell('cocktail.name', true, false, 'Коктейль', "40px"),
|
||||
createHeadCell('visitor.name', true, false, 'Клиент', "40px"),
|
||||
createHeadCell('status', true, true, 'Статус', "30px"),
|
||||
];
|
||||
|
||||
const changeOrderHandle = (row, status) => {
|
||||
let url = requests.bar.order + "?id=" + row.id;
|
||||
let isCancel = status === "CANCEL";
|
||||
let request = isCancel ? api().delete(url) : api().put(url);
|
||||
request
|
||||
.then(() => {
|
||||
createSuccess(isCancel ? "Заказ отменен" : "Заказ готов");
|
||||
let newArr = orders.filter((order) => {
|
||||
if (order.id !== row.id) {
|
||||
row.status = isCancel ? "CANCEL" : "DONE";
|
||||
return row;
|
||||
}
|
||||
return order;
|
||||
})
|
||||
setOrders(newArr);
|
||||
setSelected(null);
|
||||
setOpenModal(false);
|
||||
})
|
||||
.catch(() => createError("Ошибка изменения заказа"))
|
||||
}
|
||||
const handleSelect = (row) => {
|
||||
setSelected(row);
|
||||
setOpenModal(true);
|
||||
}
|
||||
const handleCloseModal = () => {
|
||||
setOpenModal(false);
|
||||
setSelected(null);
|
||||
};
|
||||
|
||||
const filterValues = !my ? ["DONE", "CANCEL"] : [];
|
||||
|
||||
return (
|
||||
<>
|
||||
<Loading loading={!load}/>
|
||||
<OrderModal row={selected} handleClose={handleCloseModal} open={openModal}
|
||||
handleChange={changeOrderHandle} my={my}/>
|
||||
<EnhancedTable name={"Заказы"} rows={sliced} cells={cells} handleSelect={handleSelect} filterEqual={false}
|
||||
filterField={["status"]} filterValue={filterValues}/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import * as React from "react";
|
||||
import {QueueContent} from "./QueueContent";
|
||||
|
||||
const QueuePage = () => {
|
||||
return (
|
||||
<QueueContent my={false}/>
|
||||
)
|
||||
}
|
||||
|
||||
export default QueuePage;
|
||||
Reference in New Issue
Block a user