From 696331f535a9d40926355bf8a32c944bca97a187 Mon Sep 17 00:00:00 2001 From: Adam Frederiksen <26208927+afrederiksen@users.noreply.github.com> Date: Tue, 5 Apr 2022 17:00:18 -0400 Subject: [PATCH] Fixed ingredient images and require images to be included --- .../recipes/fridger/backend/model/Ingredient.java | 2 +- .../recipes/fridger/backend/model/Recipe.java | 4 ++-- frontend/src/components/RegistrationForm.tsx | 4 ++-- frontend/src/pages/AddRecipe.tsx | 15 +++++---------- frontend/src/pages/Home.tsx | 13 ++++++++----- frontend/src/pages/Ingredient.tsx | 2 +- frontend/src/pages/Recipe.tsx | 2 +- frontend/src/pages/Verify.tsx | 4 ++-- 8 files changed, 22 insertions(+), 24 deletions(-) diff --git a/backend/src/main/java/recipes/fridger/backend/model/Ingredient.java b/backend/src/main/java/recipes/fridger/backend/model/Ingredient.java index a28cccf5..c54c1072 100644 --- a/backend/src/main/java/recipes/fridger/backend/model/Ingredient.java +++ b/backend/src/main/java/recipes/fridger/backend/model/Ingredient.java @@ -58,6 +58,6 @@ public class Ingredient { private Double cost; @Size(min = 0) - @Column(name = "imgSrc", nullable = true) + @Column(name = "imgSrc", nullable = false) private String imgSrc; } diff --git a/backend/src/main/java/recipes/fridger/backend/model/Recipe.java b/backend/src/main/java/recipes/fridger/backend/model/Recipe.java index bc379b34..28aa8906 100644 --- a/backend/src/main/java/recipes/fridger/backend/model/Recipe.java +++ b/backend/src/main/java/recipes/fridger/backend/model/Recipe.java @@ -30,7 +30,7 @@ public class Recipe { @Column(name = "author", nullable = false) private long author; - @Column(name = "authorName", nullable = false) + @Column(name = "authorName", nullable = true) private String authorName; @Size(min = 0, max = 500) @@ -38,7 +38,7 @@ public class Recipe { private String description; @Lob - @Column(name = "img_src", nullable = true) + @Column(name = "img_src", nullable = false) private String imgSrc; @Size(min = 0, max = 100000) diff --git a/frontend/src/components/RegistrationForm.tsx b/frontend/src/components/RegistrationForm.tsx index 8e1c11a2..ccf7b8dd 100644 --- a/frontend/src/components/RegistrationForm.tsx +++ b/frontend/src/components/RegistrationForm.tsx @@ -48,10 +48,10 @@ const RegistrationForm: React.FC = () => { const body = JSON.stringify(getValues()); axios.post( // `https://api.fridger.recipes/v1/auth/register`, - // `https://api.fridger.recipes/v1/auth/register`, + `https://api.fridger.recipes/v1/auth/register`, //sending test - 'http://localhost:8080/v1/auth/register', + // 'http://localhost:8080/v1/auth/register', body, config ).then( res => { diff --git a/frontend/src/pages/AddRecipe.tsx b/frontend/src/pages/AddRecipe.tsx index 4cf4ef7b..660b39e4 100644 --- a/frontend/src/pages/AddRecipe.tsx +++ b/frontend/src/pages/AddRecipe.tsx @@ -86,9 +86,8 @@ const AddRecipe: React.FC = (props: RouteComponentProps) => * * @param data */ - const onSubmit = (e: any) => { + const onSubmit = () => { // preventDefault() - e.preventDefault(); console.log("updatedValues" + getValues()); try { const config = { @@ -103,6 +102,7 @@ const AddRecipe: React.FC = (props: RouteComponentProps) => console.log("double takero") console.log(getValues('imgSrc')); const body = JSON.stringify(getValues()); + console.log("Values" + body) const res = axios.post( 'https://api.fridger.recipes/v1/recipe/', // 'https://api.fridger.recipes/v1/recipe/', @@ -165,7 +165,7 @@ const AddRecipe: React.FC = (props: RouteComponentProps) => {/* TODO: Remove Paramters From URL, this was achievable under the buttom, but form validation wasn't being checked.*/}

To add a recipe, fill out all form items

-
{await onSubmit(e); props.history.push('/recipes'); history.go(0)}} > + {onSubmit(); props.history.push('/recipes'); history.go(0)}} > Title setValue("title",e.target.value)} @@ -230,7 +230,7 @@ const AddRecipe: React.FC = (props: RouteComponentProps) => - Tags (seperated by commas) + Tags (separated by commas) setValue("tags",e.target.value)} /> @@ -241,12 +241,7 @@ const AddRecipe: React.FC = (props: RouteComponentProps) => {/* fileSetBase64FunFunctionOperation(e.currentTarget.files![0])}/> */} {/* TODO: Make it so the dropdowns are REQUIRED. */} - { - // await onSubmit(); - // }} - expand='full'> + Submit Recipe diff --git a/frontend/src/pages/Home.tsx b/frontend/src/pages/Home.tsx index 66fb8b44..799f5a2f 100644 --- a/frontend/src/pages/Home.tsx +++ b/frontend/src/pages/Home.tsx @@ -70,11 +70,13 @@ function Home() { userId: Number(context.currentUser?.id) }]); // const {id} = useParams(); - + let forcedID = context.currentUser?.id ? context.currentUser?.id : 1; useEffect(() => { //fetch("https://fridger-backend-dot-fridger-333016.ue.r.appspot.com/v1/user/goals/") //fetch('https://api.fridger.recipes/v1/user/goals/') - fetch(`https://api.fridger.recipes/v1/user/goals/?userId=${context.currentUser?.id}`) + // fetch(`https://api.fridger.recipes/v1/user/goals/?userId=${context.currentUser?.id}`) + fetch(`https://api.fridger.recipes/v1/user/goals/?userId=${forcedID}`) + .then(response => response.json()) .then(data => setGoals(data)) }, []) @@ -86,7 +88,8 @@ function Home() { recipeId: 1 }]); useEffect(() => { - fetch(`https://api.fridger.recipes/v1/favorites/?userId=${context.currentUser?.id}`) + // fetch(`https://api.fridger.recipes/v1/favorites/?userId=${context.currentUser?.id}`) + fetch(`https://api.fridger.recipes/v1/favorites/?userId=${forcedID}`) .then(response => response.json()) .then(data => setFavorites(data)) }, []) @@ -145,7 +148,7 @@ useEffect(() => {

Your Goals

- {goals.length > 0 ? ( + {(goals.length > 0 && context.currentUser !== undefined)? ( {goals.slice(-4).map(goal => @@ -166,7 +169,7 @@ useEffect(() => { ): (

Add some goals here

)}

Your Favorites

- {goals.length > 0 ? ( + {(goals.length > 0 && context.currentUser !== undefined)? ( {favorites.slice(-4).map(fav => diff --git a/frontend/src/pages/Ingredient.tsx b/frontend/src/pages/Ingredient.tsx index 01006b9e..16166555 100644 --- a/frontend/src/pages/Ingredient.tsx +++ b/frontend/src/pages/Ingredient.tsx @@ -180,7 +180,7 @@ function IngredientPage(this: any) { {/*recipePhoto*/} - recipePhoto + recipePhoto {recipe.title} diff --git a/frontend/src/pages/Recipe.tsx b/frontend/src/pages/Recipe.tsx index 5f2c3186..8abd0aa3 100644 --- a/frontend/src/pages/Recipe.tsx +++ b/frontend/src/pages/Recipe.tsx @@ -566,7 +566,7 @@ let shareUrl = `https://fridger.recipes/recipe/${id}`

Submit a Complaint:

- + diff --git a/frontend/src/pages/Verify.tsx b/frontend/src/pages/Verify.tsx index 19dbc732..fd246bb1 100644 --- a/frontend/src/pages/Verify.tsx +++ b/frontend/src/pages/Verify.tsx @@ -29,8 +29,8 @@ import React from 'react'; import { verify } from 'crypto'; import axios from 'axios'; -// const DOMAIN = "https://api.fridger.recipes" -const DOMAIN = "http://localhost:8080/" +const DOMAIN = "https://api.fridger.recipes/" +// const DOMAIN = "http://localhost:8080/" //This is the page the email verifiction will send you to function Verify() {