diff --git a/client/src/components/Create-Recipe/AddRecipe.js b/client/src/components/Create-Recipe/AddRecipe.js index 057ede5..dd34b71 100644 --- a/client/src/components/Create-Recipe/AddRecipe.js +++ b/client/src/components/Create-Recipe/AddRecipe.js @@ -37,6 +37,8 @@ export const AddRecipe = () => { // .catch((err) => console.log(err)); // }, []); + + const addRecipe = (e) => { e.preventDefault(); axios.post('http://localhost:8000/api/addRecipe', { diff --git a/client/src/components/One-Recipe/RecipeCard.js b/client/src/components/One-Recipe/RecipeCard.js index 2fb9e15..a88c3e4 100644 --- a/client/src/components/One-Recipe/RecipeCard.js +++ b/client/src/components/One-Recipe/RecipeCard.js @@ -1,11 +1,32 @@ import Nav from '../Nav/Nav' import './RecipeCard.css' +import { useLocation } from 'react-router-dom' +import { useParams } from 'react-router-dom' +import { useState } from 'react' +import { useEffect } from 'react' +import axios from 'axios' const RecipeCard = (props) => { + let location = useLocation(); + const { id } = useParams(); + const [recipe, setRecipe] = useState({}); + + console.log("This is the location", location) + + useEffect(() => { + axios.get(`http://127.0.0.1:8000/api/recipe/${id}`) + .then(response => { + console.log(response.data) + setRecipe(response.data) + }) + .catch(error => { + console.log(error, 'nope') + }) + },[]) //We pull down the list of all recipes via props so that cards can be generated for each. - const {recipe} = props + // const {recipe} = props // Switching between image and directions view @@ -20,6 +41,7 @@ const RecipeCard = (props) => { } // We need to plug in recipe.title, recipe.serves , etc + // GJL Working on this now!!!! return (
@@ -35,22 +57,22 @@ const RecipeCard = (props) => {

Servings - 4 - {/* {recipe.serves} */} + {/* 4 */} + {recipe.serves}

Prep Time - 20 mins - {/* {recipe.prepTime} */} + {/* 20 mins */} + {recipe.prepTime}

Cook Time - 40 mins - {/* {recipe.cookTime} */} + {/* 40 mins */} + {recipe.cookTime}

Ingredients Needed

Ingredients list goes here

- {/*

{recipe.ingredients}

*/} +

{recipe.ingredients}

Show Directions

@@ -58,18 +80,18 @@ const RecipeCard = (props) => { {/* Right Container */}
-

Recipe Title

- {/*

{recipe.title}

*/} + {/*

Recipe Title

*/} +

{recipe.title}


- {/* main */} - recipe + main + {/* recipe */}
- {/*

{recipe.instructions}

*/} -

directions

-

directions

+

{recipe.instructions}

+ {/*

directions

directions

+

directions

*/}
diff --git a/client/src/components/Recipe-Tile/RecipeTile.js b/client/src/components/Recipe-Tile/RecipeTile.js index 46232ff..fa94a89 100644 --- a/client/src/components/Recipe-Tile/RecipeTile.js +++ b/client/src/components/Recipe-Tile/RecipeTile.js @@ -23,7 +23,12 @@ const RecipeTile = (props) => {
{recipe.instructions}
- View Recipe + View Recipe

{recipe.creator}