Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Fixed ingredient images and require images to be included #244

Merged
merged 1 commit into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ 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)
@Column(name = "description", nullable = true)
private String description;

@Lob
@Column(name = "img_src", nullable = true)
@Column(name = "img_src", nullable = false)
private String imgSrc;

@Size(min = 0, max = 100000)
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/RegistrationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
15 changes: 5 additions & 10 deletions frontend/src/pages/AddRecipe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ const AddRecipe: React.FC<RouteComponentProps> = (props: RouteComponentProps) =>
*
* @param data
*/
const onSubmit = (e: any) => {
const onSubmit = () => {
// preventDefault()
e.preventDefault();
console.log("updatedValues" + getValues());
try {
const config = {
Expand All @@ -103,6 +102,7 @@ const AddRecipe: React.FC<RouteComponentProps> = (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/',
Expand Down Expand Up @@ -165,7 +165,7 @@ const AddRecipe: React.FC<RouteComponentProps> = (props: RouteComponentProps) =>
{/* TODO: Remove Paramters From URL, this was achievable under the buttom, but form validation wasn't being checked.*/}
<IonContent className="ion-padding">
<h1>To add a recipe, fill out all form items</h1>
<form onSubmit={async (e) =>{await onSubmit(e); props.history.push('/recipes'); history.go(0)}} >
<form onSubmit={ async () =>{onSubmit(); props.history.push('/recipes'); history.go(0)}} >
<IonItem>
<IonLabel position="floating" >Title</IonLabel>
<IonInput type="text" name="title" required onIonInput={(e: any) => setValue("title",e.target.value)}
Expand Down Expand Up @@ -230,7 +230,7 @@ const AddRecipe: React.FC<RouteComponentProps> = (props: RouteComponentProps) =>
</IonSelect>
</IonItem>
<IonItem>
<IonLabel position="floating">Tags (seperated by commas)</IonLabel>
<IonLabel position="floating">Tags (separated by commas)</IonLabel>
<IonInput name="tags" required onIonInput={(e: any) => setValue("tags",e.target.value)} />
</IonItem>
<IonItem lines="none">
Expand All @@ -241,12 +241,7 @@ const AddRecipe: React.FC<RouteComponentProps> = (props: RouteComponentProps) =>
{/* <input type="file" id="imgSrc" name="imgSrc" accept="image/png, image/jpeg" onChange={(e) => fileSetBase64FunFunctionOperation(e.currentTarget.files![0])}/> */}

{/* TODO: Make it so the dropdowns are REQUIRED. */}
<IonButton className="ion-margin-top" disabled={(!checked)}
color='primary' type="submit"
//onClick={async () =>{
// await onSubmit();
// }}
expand='full'>
<IonButton className="ion-margin-top" disabled={(!checked || getValues().ingredientIds === "" || getValues().tags === "")} color='primary' type="submit" expand='full'>
Submit Recipe
</IonButton>
<Link to="/recipes/">
Expand Down
13 changes: 8 additions & 5 deletions frontend/src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ function Home() {
userId: Number(context.currentUser?.id)
}]);
// const {id} = useParams<routeParams>();

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))
}, [])
Expand All @@ -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))
}, [])
Expand Down Expand Up @@ -145,7 +148,7 @@ useEffect(() => {
</IonRow>
</IonGrid>
<h1>Your Goals</h1>
{goals.length > 0 ? (
{(goals.length > 0 && context.currentUser !== undefined)? (
<IonGrid>
<IonRow>
{goals.slice(-4).map(goal =>
Expand All @@ -166,7 +169,7 @@ useEffect(() => {
</IonGrid>):
(<h2>Add some goals <Link to="/goals">here</Link></h2>)}
<h1>Your Favorites</h1>
{goals.length > 0 ? (
{(goals.length > 0 && context.currentUser !== undefined)? (
<IonGrid>
<IonRow>
{favorites.slice(-4).map(fav =>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Ingredient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function IngredientPage(this: any) {
<Link to={`/recipe/${recipe.id}`}>
<IonCard button routerDirection="forward">
{/*<img src={recipe.imgSrc ? recipe.imgSrc : "https://picsum.photos/1500/800"} alt="recipePhoto"/>*/}
<img src={"https://picsum.photos/1500/800"} alt="recipePhoto"/>
<img src={recipe.imgSrc} alt="recipePhoto"/>

<IonCardHeader>
<IonCardTitle>{recipe.title}</IonCardTitle>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Recipe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ let shareUrl = `https://fridger.recipes/recipe/${id}`
</IonCardContent>
<IonCardContent>
<h2>Submit a Complaint:</h2>
<Link to={`/complaint/add`}>
<Link to={`/recipe/${recipe.id}/complaint`}>
<IonFabButton >
<IonIcon icon={add} />
</IonFabButton>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/Verify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down