-
{barista.display_name}
+
{barista?.display_name}
diff --git a/src/components/Recipe/RecipeDetails.js b/src/components/Recipe/RecipeDetails.js
index 2be429f..8779675 100644
--- a/src/components/Recipe/RecipeDetails.js
+++ b/src/components/Recipe/RecipeDetails.js
@@ -5,13 +5,14 @@ import RecipeReview from './Review/RecipeReview'
import { useHistory, useParams, Link, useRouteMatch } from 'react-router-dom'
import { roundToHalfOrWhole } from 'helper/math'
import CreateRecipeReview from './Review/CreateRecipeReview'
+import { useAuth } from 'context/AuthContext'
const RecipeDetails = (props) => {
const history = useHistory()
const { url } = useRouteMatch()
const { id } = useParams()
const [, deleteRecipe] = useMutation(DELETE_RECIPES)
-
+ const { barista: userBarista } = useAuth()
const deleteRecipePressed = async () => {
await deleteRecipe({ id })
history.push(`/recipe`)
@@ -50,7 +51,6 @@ const RecipeDetails = (props) => {
recipe_reviews,
recipe_reviews_aggregate,
} = data.recipes_by_pk
-
return (
@@ -73,27 +73,31 @@ const RecipeDetails = (props) => {
{name}
- Created by {barista?.display_name} on{' '}
+ Created by {barista?.display_name} on
-
-
-
- Edit Recipe
-
-
+ {userBarista?.id === barista?.id ? (
+
+
+
+ Edit Recipe
+
+
+ ) : (
+ ''
+ )}
@@ -108,9 +112,7 @@ const RecipeDetails = (props) => {
>
Recipe Details
-
- Personal details and application.
-
+
diff --git a/src/components/Recipe/Review/CreateRecipeReview.js b/src/components/Recipe/Review/CreateRecipeReview.js
index efa60e4..5daa86b 100644
--- a/src/components/Recipe/Review/CreateRecipeReview.js
+++ b/src/components/Recipe/Review/CreateRecipeReview.js
@@ -11,7 +11,6 @@ const CreateRecipeReview = ({ id }) => {
})
const { barista } = useAuth()
const [, insertRecipeReview] = useMutation(INSERT_RECIPE_REVIEW_ONE)
-
const onChangeGenerator = (attr) => (e) => {
setState({
...state,
@@ -19,8 +18,7 @@ const CreateRecipeReview = ({ id }) => {
})
}
- const submitReview = async (e) => {
- e.preventDefault()
+ const submitReview = async () => {
await insertRecipeReview({
object: {
barista_id: barista.id,
@@ -69,28 +67,13 @@ const CreateRecipeReview = ({ id }) => {
/>
- {/*
-
-
Some HTML is okay.
-
*/}
+ )}
@@ -100,37 +83,3 @@ const CreateRecipeReview = ({ id }) => {
}
export default CreateRecipeReview
-//
-//
Create Review
-//
-//
-//
-//
-//
-//
diff --git a/src/components/Recipe/Review/RecipeReview.js b/src/components/Recipe/Review/RecipeReview.js
index 0291399..8aee9d0 100644
--- a/src/components/Recipe/Review/RecipeReview.js
+++ b/src/components/Recipe/Review/RecipeReview.js
@@ -1,6 +1,7 @@
import { useRouteMatch, Link } from 'react-router-dom'
import { DELETE_RECIPE_REVIEW } from 'queries'
import { useMutation } from 'urql'
+import { useAuth } from 'context/AuthContext'
const RecipeReview = ({ recipe_reviews }) => {
const { url } = useRouteMatch()
@@ -8,6 +9,8 @@ const RecipeReview = ({ recipe_reviews }) => {
const deleteReviewPressed = async (id) => {
await deleteReview({ id })
}
+ const { barista: userBarista } = useAuth()
+
return (
@@ -39,22 +42,32 @@ const RecipeReview = ({ recipe_reviews }) => {
{n.date_added.substring(0, 10)}
- ·
-
- Edit
-
- ·
-
+ {userBarista?.id === n.barista?.id ? (
+
+
+ ·
+
+
+ Edit
+
+
+ ·
+
+
+
+ ) : (
+ ''
+ )}