diff --git a/package-lock.json b/package-lock.json
index 04dbe61..681953e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1366,6 +1366,14 @@
"react-transition-group": "^4.4.0"
}
},
+ "@material-ui/icons": {
+ "version": "4.9.1",
+ "resolved": "https://registry.npmjs.org/@material-ui/icons/-/icons-4.9.1.tgz",
+ "integrity": "sha512-GBitL3oBWO0hzBhvA9KxqcowRUsA0qzwKkURyC8nppnC3fw54KPKZ+d4V1Eeg/UnDRSzDaI9nGCdel/eh9AQMg==",
+ "requires": {
+ "@babel/runtime": "^7.4.4"
+ }
+ },
"@material-ui/lab": {
"version": "4.0.0-alpha.56",
"resolved": "https://registry.npmjs.org/@material-ui/lab/-/lab-4.0.0-alpha.56.tgz",
diff --git a/package.json b/package.json
index 0c9435a..9d23972 100644
--- a/package.json
+++ b/package.json
@@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"@material-ui/core": "^4.11.0",
+ "@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
diff --git a/src/App.scss b/src/App.scss
index 44f4d2c..a6bf03d 100644
--- a/src/App.scss
+++ b/src/App.scss
@@ -5,6 +5,7 @@
@import "./styles/SearchResults.scss";
@import "./styles/Pictograms.scss";
@import "./styles/Restaurant.scss";
+@import "./styles/DishList.scss";
.App {
padding: 0;
diff --git a/src/Design.scss b/src/Design.scss
index b61e09c..cf1329f 100644
--- a/src/Design.scss
+++ b/src/Design.scss
@@ -1,7 +1,7 @@
$main-color: #eb9800;
$secondary-color: #307482;
$darker-color: #234f53;
-$bg-color: #ffffff;
+$bg-color: #f8f8f8;
$accents-color: #0e8496;
$lighter-color: #00d1b5;
diff --git a/src/actions/index.js b/src/actions/index.js
index 090156d..3ecca42 100644
--- a/src/actions/index.js
+++ b/src/actions/index.js
@@ -1,4 +1,5 @@
import axios from "axios";
+import * as toggles from "./toggles";
const autocomplete = (input) => {
return {
@@ -82,6 +83,7 @@ export const fetchRestaurant = (id) => {
.get("http://localhost:4000/restaurant?restaurantId=" + id)
.then((response) => {
dispatch(setRestaurant(response.data));
+ dispatch(toggles.hideDishes());
dispatch(setAppMode("APP_RESTAURANT"));
dispatch(fetchAllDishes(id));
})
@@ -102,6 +104,7 @@ export const fetchAllDishes = (id) => {
.get("http://localhost:4000/restaurant/dishes?restaurantId=" + id)
.then((response) => {
dispatch(setDishes(response.data));
+ dispatch(toggles.showDishes());
});
};
};
diff --git a/src/actions/toggles.js b/src/actions/toggles.js
new file mode 100644
index 0000000..0df67e6
--- /dev/null
+++ b/src/actions/toggles.js
@@ -0,0 +1,11 @@
+export const showDishes = () => {
+ return {
+ type: "SET_DISHLIST_VISIBLE",
+ };
+};
+
+export const hideDishes = () => {
+ return {
+ type: "SET_DISHLIST_HIDDEN",
+ };
+};
diff --git a/src/components/CardDish.js b/src/components/CardDish.js
new file mode 100644
index 0000000..a2e0416
--- /dev/null
+++ b/src/components/CardDish.js
@@ -0,0 +1,20 @@
+import React from "react";
+
+export default function CardDish(props) {
+ const { name, price, imgUrl } = props.dish;
+
+ return (
+
+ );
+}
diff --git a/src/components/DishList.js b/src/components/DishList.js
new file mode 100644
index 0000000..cc66595
--- /dev/null
+++ b/src/components/DishList.js
@@ -0,0 +1,40 @@
+import React from "react";
+import DishesCategory from "./DishesCategory";
+import { useSelector } from "react-redux";
+
+function extractCategories(dishes) {
+ var categories = new Set();
+
+ if (typeof dishes !== "undefined" && dishes.length > 0) {
+ dishes.map((dish) => categories.add(dish.category));
+ return Array.from(categories);
+ }
+}
+
+function filterDishes(dishes, category) {
+ var result = [];
+
+ dishes.map((dish) => {
+ if (dish.category === category) {
+ result.push(dish);
+ }
+ return true;
+ });
+ return result;
+}
+
+export default function DishList(props) {
+ const dishlist = useSelector((state) => state.dishes);
+ const categoriesArray = extractCategories(dishlist);
+ const categories = categoriesArray.map((category) => {
+ return (
+
+ );
+ });
+
+ return {categories}
;
+}
diff --git a/src/components/DishesCategory.js b/src/components/DishesCategory.js
new file mode 100644
index 0000000..a36e3b1
--- /dev/null
+++ b/src/components/DishesCategory.js
@@ -0,0 +1,27 @@
+import React from "react";
+import Accordion from "@material-ui/core/Accordion";
+import AccordionSummary from "@material-ui/core/AccordionSummary";
+import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
+import List from "@material-ui/core/List";
+import ListItem from "@material-ui/core/ListItem";
+import CardDish from "./CardDish";
+
+export default function DishesCategory(props) {
+ const dishes = props.dishes;
+ const dishCards = dishes.map((dish) => {
+ return (
+
+
+
+ );
+ });
+
+ return (
+
+ }>
+ {props.name}
+
+ {dishCards}
+
+ );
+}
diff --git a/src/components/Restaurant.js b/src/components/Restaurant.js
index e43be08..72b263b 100644
--- a/src/components/Restaurant.js
+++ b/src/components/Restaurant.js
@@ -1,9 +1,12 @@
import React from "react";
import Pictograms from "./Pictograms";
+import DishList from "./DishList";
+import CircularProgress from "@material-ui/core/CircularProgress";
import { useSelector } from "react-redux";
export default function Restaurant(props) {
const restaurant = useSelector((state) => state.restaurant);
+ const showDishList = useSelector((state) => state.toggles.showDishList);
function extractTags(tags) {
var results = [];
for (let [key, value] of Object.entries(tags)) {
@@ -26,7 +29,10 @@ export default function Restaurant(props) {
{restaurant.name}
{restaurant.city}
-
+
+ {showDishList === false && }
+ {showDishList === true && }
+
);
}
diff --git a/src/reducers/index.js b/src/reducers/index.js
index 2e8730f..60bd94a 100644
--- a/src/reducers/index.js
+++ b/src/reducers/index.js
@@ -5,6 +5,7 @@ import appMode from "./appMode";
import searchQuery from "./searchQuery";
import restaurant from "./restaurant";
import dishes from "./dishes";
+import toggles from "./toggles";
const rootReducer = combineReducers({
autocomplete: autoCompleteReducer,
@@ -13,6 +14,7 @@ const rootReducer = combineReducers({
searchQuery: searchQuery,
restaurant: restaurant,
dishes: dishes,
+ toggles: toggles,
});
export default rootReducer;
diff --git a/src/reducers/toggles.js b/src/reducers/toggles.js
new file mode 100644
index 0000000..396eee7
--- /dev/null
+++ b/src/reducers/toggles.js
@@ -0,0 +1,16 @@
+const initialState = {
+ showDishList: false,
+};
+
+const toggles = (state = initialState, action) => {
+ switch (action.type) {
+ case "SET_DISHLIST_VISIBLE":
+ return (state = { ...state, showDishList: true });
+ case "SET_DISHLIST_HIDDEN":
+ return (state = { ...state, showDishList: false });
+ default:
+ return state;
+ }
+};
+
+export default toggles;
diff --git a/src/styles/DishList.scss b/src/styles/DishList.scss
new file mode 100644
index 0000000..cf2550e
--- /dev/null
+++ b/src/styles/DishList.scss
@@ -0,0 +1,29 @@
+.dishlist-container {
+}
+
+h4 {
+ font-weight: 400;
+}
+
+.carddish-container {
+ margin-top: 20px;
+ margin-bottom: 20px;
+ display: flex;
+ width: 100%;
+
+ h2 {
+ font-weight: 300;
+ }
+}
+
+.carddish-img {
+ background-color: $secondary-color;
+ width: 150px;
+ height: 150px;
+ border-radius: 75px;
+ margin: 0px 20px 0px 0px;
+}
+
+.carddish-left {
+ display: flex;
+}
diff --git a/src/styles/Restaurant.scss b/src/styles/Restaurant.scss
index ec72d1a..bd74315 100644
--- a/src/styles/Restaurant.scss
+++ b/src/styles/Restaurant.scss
@@ -1,6 +1,9 @@
.restaurant-container {
min-width: 100vw;
height: 100%;
+ display: flex;
+ flex-flow: column;
+ align-items: center;
h1 {
font-weight: 100;
font-size: 3rem;
@@ -34,3 +37,7 @@
margin: 8px;
}
}
+
+.restaurant-dishes {
+ min-width: 70%;
+}