├── demo ├── Homepage.png ├── Planner.png ├── AddRecipe.png ├── RecipeBook.png ├── Recipepage.png └── ShoppingList.png ├── client ├── public │ ├── robots.txt │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── index.html ├── src │ ├── static │ │ └── CSS │ │ │ ├── graphics │ │ │ ├── CCLogo.png │ │ │ ├── Monkey.wav │ │ │ ├── jungle.png │ │ │ ├── AddRecipe.png │ │ │ ├── HomeIcon.png │ │ │ ├── SadMonkey.png │ │ │ ├── aud_chomp.wav │ │ │ ├── RecipeBook.png │ │ │ ├── ShoppingList.png │ │ │ ├── AddRecipeIcon.png │ │ │ ├── MonkeyChefLogo.png │ │ │ ├── RecipeBookIcon.png │ │ │ ├── WeeklyPlanner.png │ │ │ ├── MonkeyChefLogoBG.png │ │ │ ├── ShoppingListIcon.png │ │ │ ├── WeeklyPlannerIcon.png │ │ │ ├── MonkeyChefLogoIcon.png │ │ │ └── MonkeyChefLogo-Small.png │ │ │ ├── layout.css │ │ │ ├── recipe.css │ │ │ ├── sidenav.css │ │ │ ├── shoppinglist.css │ │ │ ├── addRecipeForm.css │ │ │ ├── homepage.css │ │ │ ├── planner.css │ │ │ └── recipebook.css │ ├── setupTests.js │ ├── App.test.js │ ├── App.js │ ├── components │ │ ├── Layout.js │ │ ├── SideNav.js │ │ ├── SidebarData.js │ │ └── RecipesList.js │ ├── index.css │ ├── reportWebVitals.js │ ├── containers │ │ ├── RecipeDetail.js │ │ ├── MealPlannerService.js │ │ ├── MealRecipeService.js │ │ ├── HomePage.js │ │ ├── ShoppingList.js │ │ ├── Recipe.js │ │ ├── RecipeBook.js │ │ ├── Planner.js │ │ └── AddRecipe.js │ ├── index.js │ ├── routes │ │ └── WebRoutes.js │ ├── App.css │ └── logo.svg ├── .gitignore ├── package.json └── README.md ├── package.json ├── .gitignore ├── server ├── .gitignore ├── package.json ├── server.js ├── helpers │ └── create_router.js └── db │ └── seeds.js └── README.md /demo/Homepage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/demo/Homepage.png -------------------------------------------------------------------------------- /demo/Planner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/demo/Planner.png -------------------------------------------------------------------------------- /demo/AddRecipe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/demo/AddRecipe.png -------------------------------------------------------------------------------- /demo/RecipeBook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/demo/RecipeBook.png -------------------------------------------------------------------------------- /demo/Recipepage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/demo/Recipepage.png -------------------------------------------------------------------------------- /client/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /demo/ShoppingList.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/demo/ShoppingList.png -------------------------------------------------------------------------------- /client/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/public/favicon.ico -------------------------------------------------------------------------------- /client/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/public/logo192.png -------------------------------------------------------------------------------- /client/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/public/logo512.png -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/CCLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/CCLogo.png -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/Monkey.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/Monkey.wav -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/jungle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/jungle.png -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/AddRecipe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/AddRecipe.png -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/HomeIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/HomeIcon.png -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/SadMonkey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/SadMonkey.png -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/aud_chomp.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/aud_chomp.wav -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/RecipeBook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/RecipeBook.png -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/ShoppingList.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/ShoppingList.png -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/AddRecipeIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/AddRecipeIcon.png -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/MonkeyChefLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/MonkeyChefLogo.png -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/RecipeBookIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/RecipeBookIcon.png -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/WeeklyPlanner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/WeeklyPlanner.png -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/MonkeyChefLogoBG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/MonkeyChefLogoBG.png -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/ShoppingListIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/ShoppingListIcon.png -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/WeeklyPlannerIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/WeeklyPlannerIcon.png -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/MonkeyChefLogoIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/MonkeyChefLogoIcon.png -------------------------------------------------------------------------------- /client/src/static/CSS/graphics/MonkeyChefLogo-Small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marshall3c03/MonkeyChef/HEAD/client/src/static/CSS/graphics/MonkeyChefLogo-Small.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "@emotion/react": "^11.7.1", 4 | "@emotion/styled": "^11.6.0", 5 | "@mui/icons-material": "^5.3.1", 6 | "@mui/material": "^5.3.1", 7 | "sweetalert": "^2.1.2" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /client/src/static/CSS/layout.css: -------------------------------------------------------------------------------- 1 | .layout { 2 | display:flex; 3 | width: 100vw; 4 | height: 100vh; 5 | overflow: hidden; 6 | } 7 | 8 | .layout-container { 9 | padding: 2rem; 10 | width: 100%; 11 | overflow: auto; 12 | } -------------------------------------------------------------------------------- /client/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /client/src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /client/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { BrowserRouter } from 'react-router-dom'; 3 | import Layout from './components/Layout'; 4 | import WebRoutes from './routes/WebRoutes'; 5 | import './App.css'; 6 | 7 | function App() { 8 | 9 | return ( 10 | 11 | 12 | 13 | 14 | 15 | ); 16 | } 17 | 18 | export default App; -------------------------------------------------------------------------------- /client/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /server/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /client/src/components/Layout.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | import SideNav from './SideNav'; 4 | 5 | import '../static/CSS/layout.css' 6 | 7 | 8 | const Layout = ({ children }) => { 9 | return ( 10 |
11 | 12 |
13 | {children} 14 |
15 |
16 | ) 17 | } 18 | 19 | export default Layout; -------------------------------------------------------------------------------- /client/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /client/src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /client/src/containers/RecipeDetail.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | const RecipeDetail = ({recipe, onRecipeClick})=>{ 4 | 5 | const handleClick = function() { 6 | onRecipeClick(recipe); 7 | }; 8 | 9 | return( 10 |
11 |
12 |

{recipe.name}

13 |

{recipe.method}

14 |
15 |
16 | ); 17 | }; 18 | 19 | export default RecipeDetail; -------------------------------------------------------------------------------- /client/src/static/CSS/recipe.css: -------------------------------------------------------------------------------- 1 | .recipe { 2 | background-color: rgba(240, 255, 240, 0.82); 3 | width:80%; 4 | padding: 1px 20px 20px 20px; 5 | } 6 | 7 | .recipe h1 { 8 | text-align: left; 9 | font-size: 50px; 10 | } 11 | 12 | .recipe-avatar { 13 | width: 10rem; 14 | } 15 | .core-recipe-details{ 16 | display: flex; 17 | flex-direction: column; 18 | } 19 | .recipe-serving-buttons{ 20 | display: flex; 21 | flex-direction: row; 22 | /* justify-content: center; */ 23 | align-items: center; 24 | } -------------------------------------------------------------------------------- /server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "meal_planner", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "seeds" : "mongo < db/seeds.js", 8 | "start" : "node server.js", 9 | "server:dev" : "nodemon server.js", 10 | "test": "echo \"Error: no test specified\" && exit 1" 11 | }, 12 | "author": "", 13 | "license": "ISC", 14 | "dependencies": { 15 | "cors": "^2.8.5", 16 | "express": "^4.17.2", 17 | "mongodb": "3.5.7", 18 | "nodemon": "^2.0.15" 19 | } 20 | } -------------------------------------------------------------------------------- /client/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /client/src/static/CSS/sidenav.css: -------------------------------------------------------------------------------- 1 | .nav-menu { 2 | background-color: rgba(58, 131, 67, 0.724); 3 | width: 100%; 4 | max-width: 5rem; 5 | min-width: 3.5rem; 6 | height: 100vh; 7 | display: flex; 8 | } 9 | 10 | .nav-text{ 11 | margin-bottom: 10px; 12 | width: 10px; 13 | list-style: none; 14 | } 15 | 16 | .nav-menu-items { 17 | display: flex; 18 | flex-direction: column; 19 | align-items: left; 20 | width: 100%; 21 | padding: 30px 0 0 0; 22 | margin-left: 10px; 23 | } 24 | 25 | .home { 26 | width: 20px; 27 | } 28 | 29 | .navIcon { 30 | width: 60px; 31 | } -------------------------------------------------------------------------------- /client/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /client/src/static/CSS/shoppinglist.css: -------------------------------------------------------------------------------- 1 | #checkbox { 2 | margin-left: 70px; 3 | width: 50px; 4 | transform: scale(2); 5 | margin-bottom: 0.7rem; 6 | } 7 | 8 | .titles { 9 | color: white; 10 | font-size: 5vw; 11 | filter: drop-shadow(0px 0px 10px #000000c8); 12 | padding-top: 40px; 13 | margin: 0; 14 | display: flex; 15 | flex-direction: row; 16 | justify-content: center; 17 | align-content: center; 18 | } 19 | 20 | .banner { 21 | background-image: url("./graphics/jungle.png"); 22 | width: 95%; 23 | height: 13vw; 24 | margin-left: auto; 25 | margin-right: auto; 26 | margin-bottom: 4vw; 27 | border-radius: 1vw; 28 | } -------------------------------------------------------------------------------- /client/src/components/SideNav.js: -------------------------------------------------------------------------------- 1 | import react from "react"; 2 | import { SidebarData } from "./SidebarData"; 3 | import { useNavigate } from "react-router-dom"; 4 | import '../static/CSS/sidenav.css' 5 | 6 | const SideNav = ( {})=>{ 7 | 8 | const navigate = useNavigate(); 9 | 10 | return( 11 | <> 12 | 23 | 24 | ); 25 | }; 26 | 27 | export default SideNav; -------------------------------------------------------------------------------- /server/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const app = express(); 3 | 4 | const cors = require('cors'); 5 | app.use(cors()); 6 | app.use(express.json()); 7 | 8 | const createRouter = require('./helpers/create_router'); 9 | const MongoClient = require('mongodb').MongoClient; 10 | 11 | MongoClient.connect('mongodb://127.0.0.1:27017', {useUnifiedTopology:true}) 12 | .then((client) => { 13 | const db = client.db('recipes'); 14 | const recipesCollection = db.collection('recipes'); 15 | const recipesRouter = createRouter(recipesCollection); 16 | app.use('/api/recipes', recipesRouter); 17 | const plannerCollection = db.collection('planner'); 18 | const plannerRouter = createRouter(plannerCollection); 19 | app.use('/api/planner', plannerRouter); 20 | }) 21 | .catch(console.error) 22 | 23 | app.listen(5000, function(){ 24 | console.log(`Listening on port ${ this.address().port }`); 25 | }); -------------------------------------------------------------------------------- /client/src/routes/WebRoutes.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { Route, Routes } from 'react-router-dom'; 3 | 4 | import HomePage from '../containers/HomePage'; 5 | import Planner from '../containers/Planner'; 6 | import RecipeBook from '../containers/RecipeBook'; 7 | import ShoppingList from '../containers/ShoppingList'; 8 | import Recipe from '../containers/Recipe'; 9 | import AddRecipe from '../containers/AddRecipe'; 10 | 11 | const WebRoutes = () => { 12 | return ( 13 | 14 | } /> 15 | } /> 16 | } /> 17 | } /> 18 | } /> 19 | } /> 20 | } /> 21 | 22 | ) 23 | } 24 | 25 | export default WebRoutes; -------------------------------------------------------------------------------- /client/src/containers/MealPlannerService.js: -------------------------------------------------------------------------------- 1 | const baseURL = "http://localhost:5000/api/planner/" 2 | 3 | const MealPlannerService = { 4 | getById(recipeId) { 5 | return fetch(baseURL + recipeId) 6 | .then(result => result.json()) 7 | }, 8 | 9 | getAll() { 10 | return fetch(baseURL) 11 | .then(result => result.json()) 12 | }, 13 | 14 | create (recipe){ 15 | const plannerRecipe = { recipeId: recipe._id, ingredients: recipe.ingredients} 16 | return fetch(baseURL, { 17 | method: 'POST', 18 | body: JSON.stringify(plannerRecipe), 19 | headers: { 'Content-Type': 'application/json' } 20 | }) 21 | .then(res => res.json()) 22 | }, 23 | 24 | delete (id) { 25 | return fetch(baseURL + id, { 26 | method: 'DELETE' 27 | }) 28 | }, 29 | 30 | update (id) { 31 | return fetch(baseURL + id, { 32 | method: 'PUT' 33 | }) 34 | } 35 | } 36 | export default MealPlannerService; -------------------------------------------------------------------------------- /client/src/containers/MealRecipeService.js: -------------------------------------------------------------------------------- 1 | const baseURL = "http://localhost:5000/api/recipes/" 2 | 3 | const MealRecipeService = { 4 | getById(recipeId) { 5 | return fetch(baseURL + recipeId) 6 | .then(result => result.json()) 7 | }, 8 | 9 | getAll() { 10 | return fetch(baseURL) 11 | .then(result => result.json()) 12 | }, 13 | 14 | create (recipe){ 15 | return fetch(baseURL, { 16 | method: 'POST', 17 | body: JSON.stringify(recipe), 18 | headers: { 'Content-Type': 'application/json' } 19 | }) 20 | .then(res => res.json()) 21 | }, 22 | 23 | delete (id) { 24 | return fetch(baseURL + id, { 25 | method: 'DELETE' 26 | }) 27 | }, 28 | 29 | update (recipe) { 30 | return fetch(baseURL + recipe.id, { 31 | method: 'PUT', 32 | body: JSON.stringify(recipe), 33 | headers: { 'Content-Type': 'application/json' } 34 | }) 35 | } 36 | } 37 | export default MealRecipeService; -------------------------------------------------------------------------------- /client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "meal_planner", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.16.1", 7 | "@testing-library/react": "^12.1.2", 8 | "@testing-library/user-event": "^13.5.0", 9 | "browser-router": "^0.2.0", 10 | "react": "^17.0.2", 11 | "react-dom": "^17.0.2", 12 | "react-router-dom": "^6.2.1", 13 | "react-scripts": "^5.0.0", 14 | "web-vitals": "^2.1.4" 15 | }, 16 | "scripts": { 17 | "start": "react-scripts start", 18 | "build": "react-scripts build", 19 | "test": "react-scripts test", 20 | "eject": "react-scripts eject" 21 | }, 22 | "eslintConfig": { 23 | "extends": [ 24 | "react-app", 25 | "react-app/jest" 26 | ] 27 | }, 28 | "browserslist": { 29 | "production": [ 30 | ">0.2%", 31 | "not dead", 32 | "not op_mini all" 33 | ], 34 | "development": [ 35 | "last 1 chrome version", 36 | "last 1 firefox version", 37 | "last 1 safari version" 38 | ] 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /client/src/components/SidebarData.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import add from '../static/CSS/graphics/AddRecipeIcon.png' 3 | import book from '../static/CSS/graphics/RecipeBookIcon.png' 4 | import planner from '../static/CSS/graphics/WeeklyPlannerIcon.png' 5 | import shoppinglist from '../static/CSS/graphics/ShoppingListIcon.png' 6 | import logo from '../static/CSS/graphics/MonkeyChefLogoIcon.png' 7 | 8 | 9 | export const SidebarData = [ 10 | { 11 | onClick: (navigate) => navigate('/'), 12 | icon: logo, 13 | cName: 'nav-text' 14 | }, 15 | { 16 | onClick: (navigate) => navigate('/addrecipe'), 17 | icon: add, 18 | cName: 'nav-text' 19 | }, 20 | { 21 | onClick: (navigate) => navigate('/recipebook'), 22 | icon: book, 23 | cName: 'nav-text' 24 | }, 25 | { 26 | onClick: (navigate) => navigate('/planner'), 27 | icon: planner, 28 | cName: 'nav-text' 29 | }, 30 | { 31 | onClick: (navigate) => navigate('/shoppinglist'), 32 | icon: shoppinglist, 33 | cName: 'nav-text' 34 | }, 35 | ] -------------------------------------------------------------------------------- /client/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | body { 6 | background-image: url("static/CSS/graphics/MonkeyChefLogoBG.png"); 7 | /* background-size: cover; */ 8 | background-repeat: no-repeat; 9 | background-size: 1200px; 10 | background-position-x: -10vw; 11 | background-position-y: center; 12 | background-color: rgb(144, 229, 165); 13 | 14 | } 15 | 16 | button{ 17 | border-radius: 50px; 18 | color: white; 19 | background-color: black; 20 | border: 0px; 21 | padding: 10px; 22 | padding-left: 20px; 23 | padding-right: 20px; 24 | margin: 5px; 25 | font-weight: 700; 26 | font-size: large; 27 | } 28 | 29 | 30 | 31 | .App-logo { 32 | height: 40vmin; 33 | pointer-events: none; 34 | } 35 | 36 | @media (prefers-reduced-motion: no-preference) { 37 | .App-logo { 38 | animation: App-logo-spin infinite 20s linear; 39 | } 40 | } 41 | 42 | .App-header { 43 | background-color: #282c34; 44 | min-height: 100vh; 45 | display: flex; 46 | flex-direction: column; 47 | align-items: center; 48 | justify-content: center; 49 | font-size: calc(10px + 2vmin); 50 | color: white; 51 | } 52 | 53 | .App-link { 54 | color: #61dafb; 55 | } 56 | 57 | @keyframes App-logo-spin { 58 | from { 59 | transform: rotate(0deg); 60 | } 61 | to { 62 | transform: rotate(360deg); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /client/src/components/RecipesList.js: -------------------------------------------------------------------------------- 1 | import react, { useState, useEffect} from "react"; 2 | import Recipe from "../containers/Recipe"; 3 | import MealPlannerService from "../containers/MealPlannerService"; 4 | import { nanoid } from 'nanoid' 5 | import swal from "sweetalert"; 6 | 7 | const RecipesList = ({recipes} )=>{ 8 | 9 | let listOfRecipes = recipes.map(recipe => { 10 | 11 | const recipeId = recipe._id; 12 | 13 | const handleClick = ()=>{ 14 | window.location.href = "/recipebook/" + recipeId 15 | } 16 | 17 | 18 | 19 | return( 20 | <> 21 |
22 | 23 |

{recipe.name}

24 | { 25 | swal({ 26 | title: "Recipe added to meal planner!", 27 | icon: "success", 28 | timer: 1500, 29 | buttons: false, 30 | className: "swal" 31 | }); 32 | MealPlannerService.create(recipe); 33 | }} src="https://icons.iconarchive.com/icons/martz90/circle-addon1/48/text-plus-icon.png" width="25px"/> 34 | 35 |
36 | 37 | ) 38 | }); 39 | 40 | return( 41 | <> 42 |
43 | {listOfRecipes} 44 |
45 | 46 | ); 47 | }; 48 | 49 | export default RecipesList; -------------------------------------------------------------------------------- /client/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | Monkey Chef 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /client/src/containers/HomePage.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { useNavigate } from "react-router-dom"; 3 | import Monkey from '../static/CSS/graphics/Monkey.wav'; 4 | 5 | import '../static/CSS/homepage.css'; 6 | 7 | const HomePage = ()=>{ 8 | 9 | const monkey = new Audio (Monkey); 10 | 11 | React.useEffect(() => { 12 | monkey.play() 13 | }, []) 14 | 15 | const navigate = useNavigate(); 16 | 17 | const handleClick = (url) => { 18 | navigate(url); // This is react routers cleaner way of doing window.location.href... use this!!. 19 | } 20 | 21 | return( 22 | <> 23 |
24 | 25 |
26 | Welcome to Monkey Chef! 27 |
28 |
29 | 30 |
31 |
handleClick("/addrecipe")}> 32 | 33 |

Add
Recipe

34 |
35 | 36 |
handleClick("/recipebook")}> 37 | 38 |

Recipe
Book

39 |
40 | 41 |
handleClick("/planner")}> 42 | 43 |

Weekly
Planner

44 |
45 | 46 |
handleClick("/shoppingList")}> 47 | 48 |

Shopping
List

49 |
50 |
51 | 52 | ); 53 | }; 54 | 55 | export default HomePage; -------------------------------------------------------------------------------- /server/helpers/create_router.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const ObjectID = require('mongodb').ObjectID; 3 | 4 | const createRouter = function (collection) { 5 | const router = express.Router(); 6 | 7 | router.get('/', (req, res) => { 8 | collection 9 | .find() 10 | .toArray() 11 | .then((documents) => res.send(documents)) 12 | .catch((error) => { 13 | console.error(error); 14 | res.status(500); 15 | res.json({status: 500, error: error}); 16 | }); 17 | }); 18 | 19 | router.get('/:id', (req, res) => { 20 | const id = req.params.id; 21 | collection 22 | .findOne({_id: ObjectID(id)}) 23 | .then((document) => res.json(document)) 24 | .catch((error) => { 25 | console.error(error); 26 | res.status(500); 27 | res.json({status: 500, error: error}); 28 | }); 29 | }); 30 | 31 | router.post('/', (req,res)=>{ 32 | const newData=req.body; 33 | req.body._id = ObjectID(req.body.id); 34 | collection 35 | .insertOne(newData) 36 | .then((result)=>{ 37 | res.json(result.ops[0]) 38 | }) 39 | .catch((err) => { 40 | console.error(err); 41 | res.status(500); 42 | res.json({ status: 500, error: err }); 43 | }); 44 | }); 45 | 46 | router.delete('/:id',(req,res)=>{ 47 | const id=req.params.id; 48 | collection 49 | .deleteOne({_id: ObjectID(id)}) 50 | .then((result)=>{ 51 | res.json(result) 52 | }) 53 | .catch((err) => { 54 | console.error(err); 55 | res.status(500); 56 | res.json({ status: 500, error: err }); 57 | }); 58 | }); 59 | 60 | router.put('/:id',(req,res)=>{ 61 | const id=req.params.id; 62 | const updatedData=req.body 63 | collection 64 | .updateOne({_id:ObjectID(id)},{$set:updatedData}) 65 | .then((result)=>{ 66 | res.json(result) 67 | }) 68 | .catch((err) => { 69 | console.error(err); 70 | res.status(500); 71 | res.json({ status: 500, error: err }); 72 | }); 73 | }); 74 | 75 | return router; 76 | }; 77 | 78 | module.exports = createRouter; -------------------------------------------------------------------------------- /client/src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Monkey Chef 2 | 3 | ![](https://raw.githubusercontent.com/Marshall3c03/CapstoneMealPlanner/main/client/src/static/CSS/graphics/MonkeyChefLogo-Small.png) 4 | 5 | ## About 6 | 7 | 8 | 10 | A web app built using Javascript, communicating with a MongoDB database through express. The front-end is displayed using React. 11 | 12 | 13 | The app allows the user to manage their recipes and meal planner. The user has full CRUD methods on the recipes, and they can assign them to a weekly meal planner, where they can also be managed. The app automatically updates a shopping list, sourcing the ingredients from the recipes in the planner, and consilidates it to avoid multiples of the same item.
14 | Other functions include search and filters for easier recipe management. 15 | 16 | 17 |
9 |
18 | 19 | ## Site 20 | 21 | ### Homepage 22 | 23 | ![](https://raw.githubusercontent.com/Marshall3c03/CapstoneMealPlanner/main/demo/Homepage.png) 24 | 25 | ### Add Recipe 26 | ![](https://raw.githubusercontent.com/Marshall3c03/CapstoneMealPlanner/main/demo/AddRecipe.png) 27 | 28 | ### Recipe Page 29 | ![](https://raw.githubusercontent.com/Marshall3c03/CapstoneMealPlanner/main/demo/Recipepage.png) 30 | 31 | ### Recipe Book 32 | ![](https://raw.githubusercontent.com/Marshall3c03/CapstoneMealPlanner/main/demo/RecipeBook.png) 33 | 34 | ### Planner 35 | ![](https://raw.githubusercontent.com/Marshall3c03/CapstoneMealPlanner/main/demo/Planner.png) 36 | 37 | ### Shopping List 38 | ![](https://raw.githubusercontent.com/Marshall3c03/CapstoneMealPlanner/main/demo/ShoppingList.png) 39 | 40 | 41 | ## How to Run 42 | ---------- 43 | 44 | 45 | ### Client: 46 | 47 | To get the application running you must install all the dependencies: 48 | 49 | npm install 50 | 51 | Start the application in development mode. running this command will open ( http://localhost:3000 ) in a browser to view the application: 52 | 53 | npm start 54 | 55 | ### Server: 56 | 57 | To get the application running you must install all the dependencies: 58 | 59 | npm install 60 | 61 | Then seed the database and run the server: 62 | 63 | npm run seeds 64 | 65 | npm run server:dev 66 | 67 | 68 | 69 | 70 | ## Built with 71 | 72 | - [JavaScript] 73 | - [React] 74 | - [MongoDB] 75 | - [Express] 76 | 77 | 78 | ## Team 79 | 80 | ### [Anita Safar](https://github.com/AnitaSafar) 81 | ### [Craig Marshall](https://github.com/Marshall3c03) 82 | ### [Ina Kurlovich](https://github.com/innessa89) 83 | ### [Ross Napier](https://github.com/RossNapier) 84 | -------------------------------------------------------------------------------- /client/src/containers/ShoppingList.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from "react"; 2 | import "../static/CSS/shoppinglist.css"; 3 | 4 | const ShoppingList = () => { 5 | 6 | const RecipesApi = [ 7 | { 8 | name: "recipes", 9 | url: "http://localhost:5000/api/planner" 10 | } 11 | ] 12 | 13 | const [recipesList, setDisplayedRecipesList] = useState([]); 14 | 15 | const shoppingList = []; 16 | 17 | useEffect(() => { 18 | loadRecipes(RecipesApi[0].url) 19 | }, []); 20 | 21 | const loadRecipes = url => { 22 | fetch(url) 23 | .then(result => result.json()) 24 | .then(recipesJson => setDisplayedRecipesList(recipesJson)) 25 | } 26 | 27 | let listOfIngredients = recipesList.map(recipe => { 28 | 29 | let fullIngredientList = recipe.ingredients.map(ingredient => { 30 | 31 | shoppingList.push(ingredient); 32 | 33 | return ( 34 | <> 35 | {ingredient.amount}{ingredient.unit} {ingredient.ingredient}
36 | 37 | )}) 38 | }); 39 | 40 | 41 | const loopedList = {}; 42 | 43 | for (let item of shoppingList) { 44 | 45 | const ingNames = Object.keys(loopedList); 46 | 47 | let found = false; 48 | const name = item.ingredient.toLowerCase(); 49 | const amount = item.amount; 50 | let unit = item.unit; 51 | let details = {"unit" : unit, "amount": amount}; 52 | 53 | for (let ingName of ingNames){ 54 | if (loopedList[name] !== undefined) { 55 | if (ingName === name) { 56 | found = true 57 | } 58 | } 59 | } 60 | if(found){ 61 | loopedList[name]["amount"] += details["amount"]; 62 | } else { 63 | loopedList[name] = details 64 | } 65 | }; 66 | 67 | let condensedList = Object.entries(loopedList); 68 | 69 | let listItems = condensedList.map((item, index) => { 70 | return ( 71 |
72 | 73 | 74 |
75 | ) 76 | }) 77 | 78 | return( 79 | <> 80 |
81 |

82 | Shopping List 83 |

84 |
85 |
86 | {listItems} 87 |
88 | 89 | ); 90 | }; 91 | 92 | export default ShoppingList; -------------------------------------------------------------------------------- /client/src/static/CSS/addRecipeForm.css: -------------------------------------------------------------------------------- 1 | .add-recipe-title{ 2 | display: flex; 3 | flex-direction: row; 4 | justify-content: center; 5 | align-content: center; 6 | font-size: 3rem; 7 | margin-top: 0; 8 | } 9 | 10 | .ingredient-text{ 11 | font-size: 20px; 12 | font-weight: bold; 13 | } 14 | .add-recipe-form-container{ 15 | display:flex; 16 | flex-direction: row; 17 | justify-content: center; 18 | padding-top: 5%; 19 | margin-left: 2rem; 20 | margin-right: 2rem; 21 | } 22 | 23 | .select-option-recipe { 24 | height: 43px; 25 | padding: 2px; 26 | padding-left: 1rem; 27 | border-radius: 20px; 28 | border: 1px solid grey; 29 | width: 300px; 30 | margin-right: 5px; 31 | font-size: 20px; 32 | font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; 33 | } 34 | 35 | .add-recipe-imageurl{ 36 | font-size: 15px; 37 | width: 30.5rem; 38 | border-radius: 20px; 39 | border: 1px solid grey; 40 | height: 2.6rem; 41 | padding-left: 1rem; 42 | } 43 | 44 | #method{ 45 | width: 30rem; 46 | height: 20rem; 47 | } 48 | 49 | #notes{ 50 | width: 30rem; 51 | height: 10rem; 52 | } 53 | 54 | .input-add-recipe { 55 | padding: 10px; 56 | padding-left: 1rem; 57 | border-radius: 20px; 58 | border: 1px solid grey; 59 | width: 272px; 60 | height: 20px; 61 | margin-right: 5px; 62 | font-size: 20px; 63 | font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; 64 | } 65 | 66 | .input-add-recipe-ingredient { 67 | padding: 10px; 68 | border-radius: 20px; 69 | border-top-right-radius: 0px; 70 | border-bottom-right-radius: 0px; 71 | border: 1px solid grey; 72 | width: 237px; 73 | height: 20px; 74 | margin-right: 0px; 75 | font-size: 20px; 76 | font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; 77 | } 78 | 79 | 80 | textarea{ 81 | border-radius: 20px; 82 | border: 1px solid grey; 83 | font-size: 22px; 84 | font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; 85 | padding: 10px; 86 | padding-left: 1rem; 87 | } 88 | 89 | .plus input{ 90 | border-top-right-radius: 20px; 91 | border-bottom-right-radius: 20px; 92 | border: 0px; 93 | background-color: black; 94 | height: 42px; 95 | width: 40px; 96 | position: relative; 97 | top: -3px; 98 | color: white; 99 | padding: 0px; 100 | text-align: center; 101 | } 102 | 103 | .save input{ 104 | border-radius: 20px; 105 | border: 0px; 106 | background-color: black; 107 | height: 3rem; 108 | width: 20rem; 109 | color: white; 110 | padding: 0px; 111 | text-align: center; 112 | } 113 | 114 | .add-recipe-save{ 115 | padding-left: 13.5rem; 116 | display: flex; 117 | justify-content: center; 118 | align-items: center; 119 | } 120 | 121 | label{ 122 | font-weight: bold; 123 | font-size: 20px; 124 | } 125 | 126 | .ingredients{ 127 | font-size: 25px; 128 | } 129 | 130 | .ingredient-form{ 131 | padding-right: 80px; 132 | } 133 | 134 | 135 | .ingredient-input{ 136 | display: flex; 137 | flex-direction: row; 138 | background-color: white; 139 | width: 20rem; 140 | } 141 | 142 | td{ 143 | padding-right:50px; 144 | min-width: 80px; 145 | } 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /client/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser. 13 | 14 | The page will reload when you make changes.\ 15 | You may also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!** 35 | 36 | If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. 39 | 40 | You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /client/src/static/CSS/homepage.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --page-button-group-margin: 30px; 3 | } 4 | 5 | .body{ 6 | background-color: black; 7 | } 8 | 9 | .homepage-banner { 10 | background-image: url("graphics/jungle.png"); 11 | width: 95%; 12 | height: 15vw; 13 | margin-left: auto; 14 | margin-right: auto; 15 | margin-top: 0.5 rem; 16 | margin-bottom: 4vw; 17 | border-radius: 1vw; 18 | } 19 | 20 | .banner-image { 21 | width: 20vw; 22 | filter: drop-shadow(0px 15px 15px #000000c8); 23 | display: flex; 24 | animation: float 3s infinite linear; 25 | display:inline-block; 26 | } 27 | 28 | @keyframes float { 29 | 0% { transform: translateY(0px) rotate(15deg); } 30 | 50% { transform: translateY(0px) rotate(0deg); } 31 | 100% { transform: translateY(0px) rotate(15deg); } 32 | } 33 | 34 | .banner-message { 35 | color: white; 36 | font-weight: 700; 37 | text-align: right; 38 | font-size: 5vw; 39 | filter: drop-shadow(0px 0px 10px #000000c8); 40 | display: inline-block; 41 | position: relative; 42 | top: -11vw; 43 | } 44 | 45 | .link-container { 46 | display: flex; 47 | flex-direction: row; 48 | flex-wrap: wrap; 49 | justify-content: center; 50 | align-items: center; 51 | margin-bottom: 2.5rem; 52 | } 53 | 54 | .home-banner-image { 55 | width: 50%; 56 | filter: drop-shadow(30px 10px 4px #070730); 57 | display:inline-block; 58 | vertical-align:top 59 | } 60 | 61 | .home-button-group { 62 | margin: var(--page-button-group-margin); 63 | background-color: white; 64 | border-radius: 10px; 65 | padding: 20px; 66 | width: 200px; 67 | height: 270px; 68 | display: flex; 69 | flex-direction: column; 70 | transition: 0.5s ease; 71 | justify-content: center; 72 | align-items: center; 73 | box-shadow: 2px 2px 5px #818181; 74 | } 75 | 76 | .home-button-group:hover { 77 | margin: var(--page-button-group-margin); 78 | background-color: rgb(255, 255, 255); 79 | transition: 1s ease; 80 | padding: 20px; 81 | width: 200px; 82 | height: 270px; 83 | display: flex; 84 | flex-direction: column; 85 | justify-content: center; 86 | align-items: center; 87 | transform: scale(1.1, 1.1); 88 | box-shadow: 0px 10px 30px #555555; 89 | } 90 | 91 | .home-button-group .home-button-title { 92 | color: black; 93 | font-weight: 500; 94 | font-size: xx-large; 95 | display: flex; 96 | margin-top: 0; 97 | margin-bottom: 1rem; 98 | text-align: center; 99 | } 100 | 101 | .home-button-image { 102 | width: 100%; 103 | height: 100%; 104 | object-fit: cover; 105 | } 106 | 107 | .banner-container { 108 | display: flex; 109 | justify-content: center; 110 | align-items: center; 111 | } 112 | 113 | .banner-container .banner-group { 114 | margin: 50px; 115 | background-color: rgb(50, 191, 183); 116 | border-radius: 10px; 117 | padding: 20px; 118 | width: 800px; 119 | height: 200px; 120 | display: flex; 121 | flex-direction: column; 122 | justify-content: center; 123 | align-items: center; 124 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px;} 125 | 126 | .banner-container .banner-group:hover { 127 | margin: 50px; 128 | background-color: rgb(27, 90, 227); 129 | box-shadow: rgba(28, 28, 162, 0.2) 0px 7px 29px 0px; 130 | border-radius: 10px; 131 | transition: all 1s ease; 132 | padding: 20px; 133 | width: 800px; 134 | height: 200px; 135 | display: flex; 136 | flex-direction: column; 137 | justify-content: center; 138 | align-items: center; 139 | } -------------------------------------------------------------------------------- /client/src/containers/Recipe.js: -------------------------------------------------------------------------------- 1 | import React, {useEffect, useState} from "react"; 2 | import { useNavigate, useParams } from "react-router-dom"; 3 | import MealPlannerService from "./MealPlannerService"; 4 | import MealRecipeService from "./MealRecipeService"; 5 | import '../static/CSS/recipe.css'; 6 | 7 | const Recipe = () => { 8 | const navigate = useNavigate(); 9 | const [currentRecipe,setCurrentRecipe] = useState(null); 10 | const [servings, setServings] = useState(4); 11 | const [mealAddedToPlanner, setMealAddedToPlanner] = useState(null); 12 | const {recipeId} = useParams(); 13 | 14 | useEffect(()=>{ 15 | MealRecipeService.getById(recipeId) 16 | .then(resultJson => setCurrentRecipe(resultJson)) 17 | }, []); 18 | 19 | const handleMinus = function() { 20 | if (servings > 1) { 21 | setServings(servings - 1); 22 | } 23 | }; 24 | 25 | const handlePlus = function() { 26 | setServings(servings + 1); 27 | }; 28 | 29 | const handleDelete = ()=>{ 30 | MealRecipeService.delete(recipeId) 31 | setTimeout(()=>navigate("/recipebook"),500) 32 | } 33 | 34 | const numOfServings = currentRecipe?.servings; 35 | 36 | const handleAdding = ()=> { 37 | MealPlannerService.create(currentRecipe) 38 | setMealAddedToPlanner() 39 | }; 40 | 41 | const handleUpdate=()=>{ 42 | MealRecipeService.update(recipeId); 43 | navigate(`/update-recipe/${recipeId}`); 44 | } 45 | 46 | let counter = 1; 47 | 48 | const fullIngredients = currentRecipe?.ingredients.map((ingredient) => { 49 | 50 | const perDesiredPortions = ((ingredient.amount/numOfServings) * servings).toFixed(1); 51 | 52 | counter += 1; 53 | return( 54 |
55 |

{perDesiredPortions} {ingredient?.unit} {ingredient.ingredient}

56 |
57 | ) 58 | }) 59 | 60 | return( 61 |
62 |

{ navigate(-1) }} 64 | src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Back_Arrow.svg/768px-Back_Arrow.svg.png" width="35px" 65 | /> {currentRecipe?.name}

66 | 67 | 68 | 75 | 82 | 83 |
69 |
70 | 71 |
Serves {servings}
72 |
73 | {fullIngredients} 74 |
76 |

Method: {currentRecipe?.method}

77 |

Notes: {currentRecipe?.notes}

78 |

Category: {currentRecipe?.category}

79 |

Dietary: {currentRecipe?.dietary}

80 |

Recommended Servings: {currentRecipe?.servings}

81 |
84 | 85 | 86 | 87 | 88 | {mealAddedToPlanner} 89 |
90 | /* // the questionmark means a Nullcoalesent meaning if current recipe has a value... then try index into name */ 91 | /* If ingredient can produce a null or undefined for the value its trying to index into.. i.e units then put a ? before the .unit */ 92 | ); 93 | }; 94 | 95 | export default Recipe; -------------------------------------------------------------------------------- /client/src/static/CSS/planner.css: -------------------------------------------------------------------------------- 1 | .planner-link-container { 2 | display: flex; 3 | flex-direction: row; 4 | flex-wrap: wrap; 5 | justify-content: center; 6 | align-items: center; 7 | margin-bottom: 50px; 8 | height: fit-content; 9 | } 10 | .search { 11 | display:flex; 12 | flex-direction: column; 13 | } 14 | 15 | .button-group { 16 | margin: var(--page-button-group-margin); 17 | background-color: white; 18 | padding: 0px; 19 | width: 12rem; 20 | height: 18rem; 21 | display: flex; 22 | flex-direction: column; 23 | transition: 1s ease; 24 | justify-content: space-between; 25 | align-items: center; 26 | box-shadow: 0px 2px 10px #939393; 27 | border-radius: 10px; 28 | } 29 | 30 | .button-group:hover { 31 | margin: var(--page-button-group-margin); 32 | background-color: rgb(255, 255, 255); 33 | transition: 1s ease; 34 | padding: 0px; 35 | width: 12rem; 36 | height: 18rem; 37 | display: flex; 38 | flex-direction: column; 39 | justify-content: space-between; 40 | align-items: center; 41 | transform: scale(1.1, 1.1); 42 | box-shadow: 0px 10px 30px #555555; 43 | } 44 | 45 | .link-container .button-group .button-text{ 46 | text-align: center; 47 | font-weight: 500; 48 | margin: 10px; 49 | margin-bottom: 0; 50 | } 51 | 52 | .button-title { 53 | flex-direction: column; 54 | } 55 | 56 | .image { 57 | margin-left:0%; 58 | float:left; 59 | height: 3rem; 60 | width: 3rem; 61 | margin-right:7px; 62 | display: cover; 63 | } 64 | 65 | .planner-recipe-group { 66 | display: flex; 67 | flex-direction: column; 68 | justify-content: left; 69 | margin-bottom: 0.5rem; 70 | padding: 0px; 71 | } 72 | 73 | .planner-recipe{ 74 | display: flex; 75 | flex-direction: row; 76 | align-items: center; 77 | margin-bottom: 1rem; 78 | width: 21rem; 79 | height: 3rem; 80 | background-color: rgba(240, 255, 240, 0.82); 81 | padding: 0rem; 82 | margin: auto; 83 | } 84 | 85 | .button-image{ 86 | border-radius: 10px; 87 | } 88 | 89 | .planner-pagetitle{ 90 | margin-top: 0; 91 | position: relative; 92 | font-size: 3rem; 93 | text-align: center; 94 | } 95 | 96 | .search input { 97 | background-color: white; 98 | margin: 0px; 99 | border-color: black; 100 | border: 2px solid black; 101 | border-bottom-left-radius: 10px; 102 | border-top-left-radius: 10px; 103 | font-size: 18px; 104 | padding: 15px; 105 | height: 30px; 106 | width: 15.6rem; 107 | } 108 | 109 | .searchInputs { 110 | margin-top: 105px; 111 | display: flex; 112 | } 113 | 114 | .searchInput{ 115 | margin-bottom: 1rem; 116 | } 117 | 118 | #clear-button { 119 | height: 64px; 120 | margin: 0px; 121 | border-bottom-left-radius: 0px; 122 | border-top-left-radius: 0px; 123 | border-bottom-right-radius: 10px; 124 | border-top-right-radius: 10px; 125 | } 126 | 127 | .button-text { 128 | text-align: center; 129 | margin: 5px; 130 | width: 10rem; 131 | padding-bottom: 10px; 132 | } 133 | 134 | .button-image{ 135 | border-top-left-radius: 10px; 136 | border-top-right-radius: 10px; 137 | width: 100%; 138 | height: 100%; 139 | object-fit: cover; 140 | } 141 | 142 | .planner-overall-container { 143 | display: flex; 144 | flex-direction: row; 145 | } 146 | 147 | .planner-overall{ 148 | margin-left: 2rem; 149 | width: 60vw; 150 | } 151 | 152 | .data-result { 153 | padding-top: 1rem; 154 | height: 75vh; 155 | overflow: scroll; 156 | overflow-x: hidden; 157 | } 158 | 159 | .planner-button-delete { 160 | margin-bottom: 1rem; 161 | } 162 | 163 | .planner-button-add { 164 | margin: 0.7rem; 165 | display: block; 166 | margin-left: auto; 167 | } 168 | 169 | .swal-sure { 170 | width: 400px; 171 | } 172 | 173 | .swal-delete { 174 | width: 360px; 175 | } -------------------------------------------------------------------------------- /client/src/static/CSS/recipebook.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --page-button-group-margin: 30px; 3 | } 4 | 5 | .body{ 6 | background-color: black; 7 | } 8 | 9 | .no-results { 10 | font-size: 2vw; 11 | height: 13vw; 12 | width: 50%; 13 | padding-top: 5%; 14 | line-height: 2vw; 15 | margin-left: auto; 16 | margin-right: auto; 17 | } 18 | 19 | .no-results-image { 20 | margin-top: -5%; 21 | width: 40%; 22 | float: left; 23 | } 24 | 25 | #searchTerm { 26 | 27 | padding: 10px; 28 | border-radius: 20px; 29 | border: 1px solid grey; 30 | width: 50%; 31 | min-width: 300px; 32 | padding-top: 13px; 33 | padding-bottom: 11px; 34 | margin-right: 0px; 35 | border-top-right-radius: 0px; 36 | border-bottom-right-radius: 0px; 37 | 38 | } 39 | 40 | .recipebook-filters-container{ 41 | display: flex; 42 | flex-direction: column; 43 | justify-content: center; 44 | align-items: center; 45 | } 46 | 47 | .recipebook-monkey { 48 | margin-right: 1rem; 49 | margin-left: 1rem; 50 | } 51 | 52 | .recipebook-title{ 53 | margin-top: 0; 54 | display: flex; 55 | justify-content: center; 56 | align-items: center; 57 | font-size: 3rem; 58 | } 59 | 60 | .recipebook-search-container{ 61 | margin-top: 2rem; 62 | display: flex; 63 | flex-direction: row; 64 | justify-content: center; 65 | align-items: center; 66 | } 67 | 68 | .recipebook-filters-container{ 69 | margin-top: 2rem; 70 | display: flex; 71 | flex-direction: row; 72 | justify-content: center; 73 | align-items: center; 74 | } 75 | 76 | #search-button { 77 | border-top-left-radius: 0px; 78 | border-bottom-left-radius: 0px; 79 | border : 0px; 80 | margin-left: 0px; 81 | } 82 | 83 | .home-button-group { 84 | margin: var(--page-button-group-margin); 85 | background-color: white; 86 | border-radius: 10px; 87 | padding: 20px; 88 | width: 200px; 89 | height: 300px; 90 | display: flex; 91 | flex-direction: column; 92 | transition: 0.5s ease; 93 | justify-content: center; 94 | align-items: center; 95 | box-shadow: 2px 2px 5px #818181; 96 | } 97 | 98 | .home-button-group:hover { 99 | margin: var(--page-button-group-margin); 100 | background-color: rgb(255, 255, 255); 101 | transition: 1s ease; 102 | padding: 20px; 103 | width: 200px; 104 | height: 300px; 105 | display: flex; 106 | flex-direction: column; 107 | justify-content: center; 108 | align-items: center; 109 | transform: scale(1.1, 1.1); 110 | box-shadow: 0px 10px 30px #555555; 111 | } 112 | 113 | .home-button-group .button-title { 114 | color: black; 115 | font-weight: 500; 116 | font-size: xx-large; 117 | display: flex; 118 | margin-bottom: 30px; 119 | text-align: center; 120 | } 121 | 122 | .recipe-button-group { 123 | margin: var(--page-button-group-margin); 124 | background-color: white; 125 | padding: 0px; 126 | width: 12rem; 127 | height: 18rem; 128 | display: flex; 129 | flex-direction: column; 130 | transition: 1s ease; 131 | justify-content: space-between; 132 | align-items: center; 133 | box-shadow: 0px 2px 10px #939393; 134 | border-radius: 10px; 135 | } 136 | 137 | 138 | 139 | 140 | .recipe-button-group:hover { 141 | margin: var(--page-button-group-margin); 142 | background-color: rgb(255, 255, 255); 143 | transition: 1s ease; 144 | padding: 0px; 145 | width: 12rem; 146 | height: 18rem; 147 | display: flex; 148 | flex-direction: column; 149 | justify-content: space-between; 150 | align-items: center; 151 | transform: scale(1.1, 1.1); 152 | box-shadow: 0px 10px 30px #555555; 153 | } 154 | 155 | .recipe-button-text{ 156 | text-align: center; 157 | width: 10rem; 158 | } 159 | 160 | .button-image { 161 | width: 100%; 162 | height: 62%; 163 | object-fit: cover; 164 | border-bottom-left-radius: 0; 165 | border-bottom-right-radius: 0; 166 | } 167 | 168 | .recipe-button-image{ 169 | margin-bottom: 1rem; 170 | } 171 | 172 | .banner-container { 173 | display: flex; 174 | justify-content: center; 175 | align-items: center; 176 | } 177 | 178 | .banner-container .banner-group { 179 | margin: 50px; 180 | background-color: rgb(50, 191, 183); 181 | border-radius: 10px; 182 | padding: 20px; 183 | width: 800px; 184 | height: 200px; 185 | display: flex; 186 | flex-direction: column; 187 | justify-content: center; 188 | align-items: center; 189 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px;} 190 | 191 | .banner-container .banner-group:hover { 192 | margin: 50px; 193 | background-color: rgb(152, 29, 29); 194 | box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; 195 | border-radius: 10px; 196 | transition: all 1s ease; 197 | padding: 20px; 198 | width: 800px; 199 | height: 200px; 200 | display: flex; 201 | flex-direction: column; 202 | justify-content: center; 203 | align-items: center; 204 | } 205 | 206 | 207 | .banner-container .banner-group .banner-company-text{ 208 | position: relative; 209 | top: -25px; 210 | right: 325px; 211 | color: white; 212 | } 213 | 214 | .banner-container .banner-group .banner-instructions .instruction1{ 215 | color: white; 216 | font-weight: 600; 217 | position: relative; 218 | top: -85px; 219 | bottom: 0px; 220 | right: 0px; 221 | left: 200px; 222 | } 223 | 224 | .banner-container .banner-group .banner-instructions .instruction2{ 225 | color: white; 226 | font-weight: 600; 227 | position: relative; 228 | top: -60px; 229 | bottom: 0px; 230 | right: 0px; 231 | left: 175px; 232 | } 233 | 234 | .banner-container .banner-group .banner-instructions .instruction3{ 235 | color: white; 236 | font-weight: 600; 237 | position: relative; 238 | top: -35px; 239 | bottom: 0px; 240 | right: 0px; 241 | left: 150px; 242 | } 243 | 244 | .recipe-book-link-container { 245 | display: flex; 246 | flex-direction: row; 247 | flex-wrap: wrap; 248 | justify-content: center; 249 | align-items: center; 250 | margin-top: 2rem; 251 | margin-bottom: 5rem; 252 | } 253 | 254 | .swal { 255 | width: 420px; 256 | padding-bottom: 30px; 257 | } -------------------------------------------------------------------------------- /client/src/containers/RecipeBook.js: -------------------------------------------------------------------------------- 1 | import React, {useEffect, useState} from "react"; 2 | import RecipesList from "../components/RecipesList"; 3 | import '../static/CSS/recipebook.css' 4 | import logo from '../static/CSS/graphics/MonkeyChefLogo.png' 5 | import Chomp from '../static/CSS/graphics/aud_chomp.wav'; 6 | 7 | const RecipeBook = () => { 8 | 9 | const chomp = new Audio (Chomp); 10 | 11 | const RecipesApi = [ 12 | { 13 | name: "recipes", 14 | url: "http://localhost:5000/api/recipes" 15 | } 16 | ] 17 | 18 | const [displayedRecipesList, setDisplayedRecipesList] = useState([]); 19 | const [permanantRecipesList, setPermanantRecipesList] = useState([]); 20 | const [searchTerm, setSearchTerm] = useState([]); 21 | const [noResults, setNoResults] = useState(false); 22 | 23 | const handleSearch = (ev) => setSearchTerm(ev.target.value); 24 | 25 | useEffect(() => { 26 | loadRecipes(RecipesApi[0].url) 27 | return () => { 28 | } 29 | }, []) 30 | 31 | const loadRecipes = url => { 32 | fetch(url) 33 | .then(result => result.json()) 34 | .then(recipesJson => { 35 | setDisplayedRecipesList(recipesJson) 36 | setPermanantRecipesList(recipesJson)}) 37 | } 38 | 39 | const reloadRecipes = () => { 40 | setDisplayedRecipesList(permanantRecipesList) 41 | setNoResults(false) 42 | setSearchTerm("") 43 | } 44 | 45 | const recipeByTitle = displayedRecipesList.slice(0); 46 | recipeByTitle.sort(function(a,b) { 47 | let x = a.name.toLowerCase(); 48 | let y = b.name.toLowerCase(); 49 | return x < y ? -1 : x > y ? 1 : 0; 50 | }); 51 | 52 | const recipeByDefault = displayedRecipesList.slice(0); 53 | recipeByDefault.sort(function(a,b) { 54 | let x = a._id; 55 | let y = b._id; 56 | return x < y ? -1 : x > y ? 1 : 0; 57 | }); 58 | 59 | const sortName = function() { 60 | setDisplayedRecipesList(recipeByTitle); 61 | } 62 | 63 | const sortDefault = function() { 64 | setDisplayedRecipesList(recipeByDefault.reverse()); 65 | } 66 | 67 | let foundItems = []; 68 | 69 | const search = function() { 70 | setDisplayedRecipesList(null); 71 | 72 | foundItems = []; 73 | displayedRecipesList.map(recipe => { 74 | if (recipe.name.toLowerCase().includes(searchTerm.toLowerCase()) === true) { 75 | foundItems.push(recipe) 76 | } else { 77 | // setNoResults(

No results

Your search didn't find
any recipes
) 78 | setNoResults(true) 79 | } 80 | setDisplayedRecipesList(foundItems); 81 | document.getElementById('searchTerm').value = ""; 82 | }) 83 | chomp.play() 84 | } 85 | 86 | const filterByCategory = function(filterBy) { 87 | foundItems = []; 88 | permanantRecipesList.map(recipe => { 89 | if (recipe.category.toLowerCase() === filterBy) { 90 | foundItems.push(recipe) 91 | } 92 | }) 93 | console.log("FoundItems", foundItems); 94 | setDisplayedRecipesList(foundItems) 95 | } 96 | 97 | const filterByDiet = function(filterBy) { 98 | foundItems = []; 99 | permanantRecipesList.map(recipe=> { 100 | if (recipe?.dietary?.toLowerCase() === filterBy) { 101 | foundItems.push(recipe) 102 | } 103 | }) 104 | setDisplayedRecipesList(foundItems) 105 | } 106 | 107 | const filterByBreakfast = function() { 108 | filterByCategory("breakfast"); 109 | } 110 | 111 | const filterByLunch = function() { 112 | filterByCategory("lunch"); 113 | } 114 | 115 | const filterByDinner = function() { 116 | filterByCategory("dinner"); 117 | } 118 | 119 | const filterBySweet = function() { 120 | filterByCategory("sweet"); 121 | } 122 | 123 | const filterByVegan = function() { 124 | filterByDiet("vegan"); 125 | } 126 | 127 | const filterByVegetarian = function() { 128 | filterByDiet("vegetarian"); 129 | } 130 | 131 | const filterByGlutenFree = function() { 132 | filterByDiet("gluten-free"); 133 | } 134 | 135 | return ( 136 |
137 |

Your Recipes

138 |
139 | 140 | 141 | 142 |
143 |
144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 |
156 | 157 | {/* {noResults ?

No results

Your search didn't find
any recipes
: null} */} 158 |
159 | ); 160 | }; 161 | 162 | export default RecipeBook; -------------------------------------------------------------------------------- /client/src/containers/Planner.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect, useMemo} from "react"; 2 | import MealPlannerService from "./MealPlannerService"; 3 | import '../static/CSS/planner.css' 4 | import { nanoid } from 'nanoid' 5 | import swal from "sweetalert"; 6 | 7 | function Planner({}){ 8 | 9 | 10 | const PlannerApi = [ 11 | { 12 | name: "planner", 13 | url: "http://localhost:5000/api/planner" 14 | }, 15 | { 16 | name: "recipe", 17 | url: "http://localhost:5000/api/recipes" 18 | }, 19 | ] 20 | 21 | const [recipesInPlannerList, setrecipesInPlannerList] = useState([]); 22 | const [recipeBookList, setRecipeBookList] = useState([]); 23 | const [plannerDBList, setPlannerDBList] = useState([]); 24 | const [filteredRecipeBookList, setFilteredRecipeBookList] = useState([]); 25 | const [wordEntered, setWordEntered] = useState(""); 26 | 27 | useEffect(() => { 28 | loadAllRecipes(PlannerApi[1].url); 29 | },[]); 30 | 31 | const loadAllRecipesInPlanner = (url, allRecipes) => { 32 | fetch(url) 33 | .then(result => result.json()) 34 | .then(response => { 35 | const allRecipesInPlanner = allRecipes 36 | .filter(r => response.some(p => p.recipeId === r._id)); 37 | setrecipesInPlannerList(allRecipesInPlanner); 38 | setPlannerDBList(response); 39 | setRecipeBookList(allRecipes); 40 | setFilteredRecipeBookList(allRecipes); 41 | }); 42 | }; 43 | 44 | const loadAllRecipes = url => { 45 | fetch(url) 46 | .then(result => result.json()) 47 | .then(async (allRecipes) => { 48 | await loadAllRecipesInPlanner(PlannerApi[0].url, allRecipes); 49 | }) 50 | }; 51 | 52 | const recipesSearchList = filteredRecipeBookList?.map(recipe=>{ 53 | const handleAdding = ()=> { 54 | MealPlannerService.create(recipe) 55 | .then(savedRecipe => setrecipesInPlannerList([...recipesInPlannerList, savedRecipe])) 56 | } 57 | return( 58 |
59 |
60 | 61 |

{recipe.name}

62 | 64 |
65 |
66 | ) 67 | }); 68 | 69 | const handleFilter = (event) => { 70 | const searchWord = event.target.value; 71 | setWordEntered(searchWord); 72 | if (searchWord === "") { 73 | setFilteredRecipeBookList(recipeBookList); 74 | } else { 75 | setFilteredRecipeBookList(recipeBookList.filter((value) => { 76 | return value.name.toLowerCase().includes(searchWord.toLowerCase()) 77 | })); 78 | } 79 | }; 80 | 81 | const clearInput = () => { 82 | setWordEntered(""); 83 | setFilteredRecipeBookList(recipeBookList); 84 | }; 85 | 86 | const displayrecipesInPlannerList= useMemo(() => recipesInPlannerList?.map(recipe=>{ 87 | 88 | const recipeId = recipe._id; 89 | 90 | const handleImageClick = ()=>{ 91 | window.location.href = "/recipebook/" + recipe._id 92 | } 93 | 94 | return( 95 |
96 | 97 |

{recipe.name}

98 | { 100 | swal({ 101 | title: "Are you sure?", 102 | icon: "warning", 103 | buttons: true, 104 | dangerMode: true, 105 | buttons: ['No!', 'Yes..'], 106 | className: "swal-sure" 107 | }) 108 | .then((willDelete) => { 109 | if (willDelete) { 110 | const plannerId = plannerDBList.find(p => p.recipeId === recipe._id)._id; 111 | MealPlannerService.delete(plannerId).then(() => { 112 | var array = [...recipesInPlannerList]; 113 | var index = array.indexOf(recipe) 114 | if (index !== -1) { 115 | array.splice(index, 1); 116 | setrecipesInPlannerList(array); 117 | } 118 | }); 119 | swal("Recipe deleted!", { 120 | icon: "error", 121 | timer: 1500, 122 | buttons: false, 123 | className: "swal-delete" 124 | }); 125 | }});; 126 | }} 127 | src="https://findicons.com/files/icons/1262/amora/256/delete.png" width="25px"/> 128 |
129 | )}), [recipesInPlannerList, plannerDBList]); 130 | 131 | return( 132 |
133 |
134 |
135 |
136 | 140 |
141 | 142 |
143 | {recipesSearchList} 144 |
145 |
146 | 147 |
148 |

Planner

149 |
150 | {displayrecipesInPlannerList} 151 |
152 |
153 | 154 |
155 |
156 | ) 157 | }; 158 | 159 | export default Planner; -------------------------------------------------------------------------------- /client/src/containers/AddRecipe.js: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from "react"; 2 | import { useParams } from "react-router-dom"; 3 | import { useNavigate } from "react-router-dom"; 4 | import MealRecipeService from "./MealRecipeService"; 5 | import swal from "sweetalert"; 6 | import "../static/CSS/addRecipeForm.css"; 7 | 8 | const AddRecipe = ()=>{ 9 | 10 | const navigate = useNavigate(); 11 | 12 | const [name, setName] = useState(""); 13 | const [amount, setAmount] = useState(""); 14 | const [unit, setUnit] = useState(undefined); 15 | const [ingredient, setIngredient] = useState(""); 16 | const [ingredients, setIngredients] = useState([]); 17 | const [image, setImage] = useState(); 18 | const [method, setMethod] = useState(); 19 | const [servings, setServings]=useState(undefined); 20 | const [category, setCategory]= useState(""); 21 | const [dietary,setDietary]=useState(""); 22 | const [notes, setNotes]=useState(""); 23 | const {recipeId} = useParams(); 24 | 25 | useEffect(()=>{ 26 | if(recipeId){ 27 | MealRecipeService.getById(recipeId) 28 | .then(resultJson => { 29 | setName(resultJson.name); 30 | setAmount(resultJson.amount); 31 | setUnit(resultJson.unit); 32 | setIngredient(resultJson.ingredient); 33 | setIngredients(resultJson.ingredients); 34 | setImage(resultJson.image); 35 | setMethod(resultJson.method); 36 | setNotes(resultJson.notes); 37 | setServings(resultJson.servings); 38 | setCategory(resultJson.category); 39 | setDietary(resultJson.dietary); 40 | }); 41 | } 42 | }, {}); 43 | 44 | const handleNameChange = (ev) => setName(ev.target.value); 45 | const handleAmountChange = (ev) => setAmount(parseFloat(ev.target.value)); 46 | const handleUnitChange = (ev) => setUnit(ev.target.value === "" ? undefined : ev.target.value); 47 | const handleIngredientChange = (ev) => setIngredient(ev.target.value); 48 | const handleMethodChange = (ev) => setMethod(ev.target.value); 49 | const handleImageChange = (ev) => setImage(ev.target.value); 50 | const handleServingsChange = (ev) => setServings(parseInt(ev.target.value === "" ? undefined : ev.target.value)); 51 | const handleCategoryChange = (ev) => setCategory(ev.target.value); 52 | const handleDietaryChange = (ev) => setDietary(ev.target.value); 53 | const handleNotesChange=(ev)=>setNotes(ev.target.value); 54 | 55 | const clearState= ()=>{ 56 | setName(""); 57 | setIngredient(""); 58 | setUnit(""); 59 | setAmount(); 60 | setIngredients([]); 61 | setMethod(""); 62 | setImage(""); 63 | setServings(); 64 | setCategory(""); 65 | setDietary(""); 66 | setNotes(""); 67 | } 68 | 69 | const handleNewIngredientClick = (e) => { 70 | e.preventDefault(); 71 | setAmount(); 72 | setUnit(undefined); 73 | setIngredient(""); 74 | const newIngredient = 75 | {"amount" : amount, 76 | "unit" : unit, 77 | "ingredient": ingredient 78 | }; 79 | setIngredients([...ingredients, newIngredient]) 80 | }; 81 | 82 | const allIngredients = ()=>{ 83 | return ingredients.map(ingredient =>{ 84 | return( 85 |

{ingredient.amount} {ingredient.unit} {ingredient.ingredient}

86 | ) 87 | }) 88 | }; 89 | 90 | const handleSubmit = (e) =>{ 91 | if(recipeId){ 92 | e.preventDefault() 93 | const updatedRecipe = { 94 | "id": recipeId, 95 | "name": name, 96 | "ingredients": ingredients, 97 | "image" : image, 98 | "method": method, 99 | "servings": servings, 100 | "category": category, 101 | "dietary":dietary, 102 | "notes": notes, 103 | "amount" : amount, 104 | "unit" : unit, 105 | "ingredient": ingredient 106 | }; 107 | MealRecipeService.update(updatedRecipe).then(() => clearState()); 108 | } else { 109 | e.preventDefault() 110 | const newRecipe = { 111 | "name": name, 112 | "ingredients": ingredients, 113 | "image" : image, 114 | "method": method, 115 | "servings": servings, 116 | "category": category, 117 | "dietary":dietary, 118 | "notes": notes 119 | }; 120 | MealRecipeService.create(newRecipe).then(() => clearState()); 121 | } 122 | setTimeout(navigate('/recipebook'),10000) 123 | }; 124 | 125 | return( 126 |
127 |

Recipe Form

128 |
129 |
130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 148 | 149 | 150 | 151 | 152 | 153 | 154 |
155 | {allIngredients()} 156 |
157 |
158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 177 | 178 | 179 | 180 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 |