web client v0.6 (add dish)
This commit is contained in:
33
src/components/Output/EditDishList.js
Normal file
33
src/components/Output/EditDishList.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import React from "react";
|
||||
import { useSelector } from "react-redux";
|
||||
import List from "@material-ui/core/List";
|
||||
import ListItem from "@material-ui/core/ListItem";
|
||||
|
||||
export default function EditDishList(props) {
|
||||
const filterDishes = (dishes, category) => {
|
||||
var result = [];
|
||||
dishes.map((dish) => {
|
||||
if (dish.category === category) {
|
||||
result.push(dish);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
const allDishes = useSelector((state) => state.dishes);
|
||||
const thisCategoryDishes = filterDishes(allDishes, props.category);
|
||||
const Dishes = thisCategoryDishes.map((dish) => {
|
||||
return <ListItem key={dish._id}>{dish.name}</ListItem>;
|
||||
});
|
||||
|
||||
return (
|
||||
<List>
|
||||
{thisCategoryDishes.length === 0 ? (
|
||||
<ListItem>Kategoria pusta</ListItem>
|
||||
) : (
|
||||
Dishes
|
||||
)}
|
||||
</List>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user