Skip to content

Commit

Permalink
Fixed frontend, need to finish up test
Browse files Browse the repository at this point in the history
  • Loading branch information
KELLOGGS522 committed Jan 3, 2023
1 parent 59da416 commit 0967a04
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ jsuite/db.sqlite3
jsuite/.coverage
__pycache__/
data/db/
/jsuite/jrecipes/schema/.graphqlconfig
/jsuite/jrecipes/schema/schema.graphql
2 changes: 1 addition & 1 deletion jsuite-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"start": "WATCHPACK_POLLING=true react-scripts start",
"build": "CI=false && react-scripts build",
"test": "react-scripts test",
"test:coverage": "react-scripts test --coverage --watchAll=false",
Expand Down
64 changes: 37 additions & 27 deletions jsuite-frontend/src/routes/Recipes/RecipeView/RecipeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,34 @@ import { SELECT_RECIPE_PROMPT } from "../../../constants";
import LoadingMessage from "../../../components/LoadingMessage/LoadingMessage";

export const RECIPE_BY_ID_QUERY = gql`
query RecipeById($id: ID!) {
recipeById(id: $id) {
title
description
categories{
name
}
portionSize
prepTime
cookTime
ingredients{
name
allergens{
type
query RecipeById($id: ID!) {
recipeById(id: $id) {
title
description
categories {
name
}
servings
prepTime
cookTime
ingredientList{
ingredient {
name
allergens {
type
}
}
unit
quantity
}
instructions{
text
}
additionalNotes
dateUpdated
dateCreated
}
}
instructions
additionalNotes
nutritionalInfo
dateCreated
}
}
`;

type Props = {
Expand All @@ -51,21 +57,25 @@ const RecipeView = (props: Props) => {
<br />
{data.recipeById.categories[0].name} {/*TEMPORARY FOR TESTING*/}
<br />
{data.recipeById.portionSize}
{data.recipeById.servings}
<br />
{data.recipeById.prepTime}
<br />
{data.recipeById.cookTime}
<br />
{data.recipeById.ingredients[0].name} {/*TEMPORARY FOR TESTING*/}
<br />
{data.recipeById.ingredients[0].allergens[0].type} {/*TEMPORARY FOR TESTING*/}
<br />
{data.recipeById.instructions}
{data.recipeById.ingredientList[0].ingredient.name}
<br/>
{data.recipeById.ingredientList[0].ingredient.allergens[0].type}
<br/>
{data.recipeById.ingredientList[0].unit} {/*TEMPORARY FOR TESTING*/}
<br />
{data.recipeById.ingredientList[0].quantity} {/*TEMPORARY FOR TESTING*/}
<br />
{data.recipeById.instructions[0].text}
<br />
{data.recipeById.additionalNotes}
<br />
{data.recipeById.nutritionalInfo}
{data.recipeById.dateUpdated}
<br />
{data.recipeById.dateCreated}
</View>
Expand Down
4 changes: 2 additions & 2 deletions jsuite/jrecipes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __str__(self):
class InstructionStep(models.Model):
text = models.TextField()
#image = models.ImageField(upload_to=None, blank=True) # TODO FIX IMAGES LATER
sub_steps = models.ManyToManyField('self', blank=True)
sub_steps = models.ManyToManyField('self', blank=True, symmetrical=False)

class Meta:
ordering = ['-id']
Expand Down Expand Up @@ -111,7 +111,7 @@ class Recipe(models.Model):
cook_time = models.IntegerField(blank=True, null=True) # In minutes
ingredient_list = models.ManyToManyField(IngredientListItem, help_text='Select an IngredientListItem for this recipe', blank=True)
allergens = models.ManyToManyField(Allergen, blank=True)
instructions = models.OneToOneField(InstructionStep, on_delete=models.CASCADE)
instructions = models.ManyToManyField(InstructionStep)
additional_notes = models.TextField(blank=True)
date_updated = models.DateField(auto_now=True)
date_created = models.DateField(auto_now_add=True)
Expand Down

0 comments on commit 0967a04

Please sign in to comment.