web client v0.8
This commit is contained in:
@@ -9,6 +9,7 @@ import EditDishList from "./EditDishList";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import YesNo from "../Dialogs/YesNo";
|
||||
import { notification } from "../../actions";
|
||||
import Tooltip from "@material-ui/core/Tooltip";
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
@@ -75,16 +76,22 @@ export default function EditCategoriesList(props) {
|
||||
>
|
||||
<h4>{category}</h4>
|
||||
<div className="editRestaurant-categorySpan">
|
||||
<IconButton
|
||||
color="primary"
|
||||
component="span"
|
||||
onClick={() => handleDeleteButton(category)}
|
||||
>
|
||||
<DeleteIcon />
|
||||
</IconButton>
|
||||
<Tooltip title="Usuń">
|
||||
<IconButton
|
||||
color="primary"
|
||||
component="span"
|
||||
onClick={() => handleDeleteButton(category)}
|
||||
>
|
||||
<DeleteIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</AccordionSummary>
|
||||
<EditDishList restaurantId={props.restaurantId} category={category} />
|
||||
<EditDishList
|
||||
restaurantId={props.restaurantId}
|
||||
lunchMenu={props.lunchMenu}
|
||||
category={category}
|
||||
/>
|
||||
</Accordion>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -11,9 +11,14 @@ import axios from "axios";
|
||||
import { backend } from "../../config";
|
||||
import YesNo from "../Dialogs/YesNo";
|
||||
import { notification, fetchAllDishes } from "../../actions";
|
||||
import Tooltip from "@material-ui/core/Tooltip";
|
||||
import FastfoodIcon from "@material-ui/icons/Fastfood";
|
||||
import AddToSet from "../Dialogs/AddToSet";
|
||||
import { hideBackdrop, showBackdrop } from "../../actions/toggles";
|
||||
|
||||
export default function EditDishList(props) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [setListOpen, setSetListOpen] = useState(false);
|
||||
const [selectedDish, setDish] = useState("");
|
||||
const history = useHistory();
|
||||
const dispatch = useDispatch();
|
||||
@@ -80,6 +85,38 @@ export default function EditDishList(props) {
|
||||
});
|
||||
};
|
||||
|
||||
const handleAddToSet = (dishId) => {
|
||||
setDish(dishId);
|
||||
setSetListOpen(true);
|
||||
};
|
||||
|
||||
const addToSet = (setName) => {
|
||||
setSetListOpen(false);
|
||||
const data = {
|
||||
setName: setName,
|
||||
restaurantId: props.restaurantId,
|
||||
dishId: selectedDish,
|
||||
action: "add",
|
||||
};
|
||||
dispatch(showBackdrop());
|
||||
axios({
|
||||
method: "POST",
|
||||
url: backend + "/restaurant/lunch",
|
||||
data: data,
|
||||
headers: {
|
||||
"x-auth-token": token,
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
dispatch(hideBackdrop());
|
||||
dispatch(notification("Dodano do zestawu.", "success"));
|
||||
})
|
||||
.catch((error) => {
|
||||
dispatch(hideBackdrop());
|
||||
dispatch(notification("Wystąpił błąd.", "error"));
|
||||
});
|
||||
};
|
||||
|
||||
const allDishes = useSelector((state) => state.dishes);
|
||||
const thisCategoryDishes = filterDishes(allDishes, props.category);
|
||||
const Dishes = thisCategoryDishes.map((dish) => {
|
||||
@@ -98,24 +135,39 @@ export default function EditDishList(props) {
|
||||
<h3>{dish.name}</h3>
|
||||
</div>
|
||||
<div className="editRestaurant-dishRight">
|
||||
<Switch
|
||||
checked={!dish.hidden}
|
||||
onClick={() => handleSetDishVisibility(dish._id, dish.hidden)}
|
||||
/>
|
||||
<IconButton
|
||||
color="primary"
|
||||
component="span"
|
||||
onClick={() => selectDish(dish._id)}
|
||||
>
|
||||
<DeleteIcon />
|
||||
</IconButton>
|
||||
<IconButton
|
||||
color="primary"
|
||||
component="span"
|
||||
onClick={() => history.push(`/editDish/${dish._id}`)}
|
||||
>
|
||||
<EditIcon />
|
||||
</IconButton>
|
||||
<Tooltip title="Widoczność">
|
||||
<Switch
|
||||
checked={!dish.hidden}
|
||||
onClick={() => handleSetDishVisibility(dish._id, dish.hidden)}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip title="Usuń">
|
||||
<IconButton
|
||||
color="primary"
|
||||
component="span"
|
||||
onClick={() => selectDish(dish._id)}
|
||||
>
|
||||
<DeleteIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Tooltip title="Edytuj">
|
||||
<IconButton
|
||||
color="primary"
|
||||
component="span"
|
||||
onClick={() => history.push(`/editDish/${dish._id}`)}
|
||||
>
|
||||
<EditIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Tooltip title="Dodaj do zestawu">
|
||||
<IconButton
|
||||
color="primary"
|
||||
component="span"
|
||||
onClick={() => handleAddToSet(dish._id)}
|
||||
>
|
||||
<FastfoodIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</ListItem>
|
||||
@@ -125,6 +177,12 @@ export default function EditDishList(props) {
|
||||
return (
|
||||
<List>
|
||||
<YesNo open={open} cancel={onCancel} accept={onAccept} />
|
||||
<AddToSet
|
||||
lunchMenu={props.lunchMenu}
|
||||
open={setListOpen}
|
||||
cancel={() => setSetListOpen(false)}
|
||||
add={(setName) => addToSet(setName)}
|
||||
/>
|
||||
{thisCategoryDishes.length === 0 ? (
|
||||
<ListItem style={{ marginLeft: "14px", fontSize: "12px" }}>
|
||||
Kategoria pusta
|
||||
|
||||
Reference in New Issue
Block a user