From 02e4a5d7fa9b1dd20c9f4d4a845154ccbbf30b90 Mon Sep 17 00:00:00 2001 From: dvirlabs Date: Fri, 5 Dec 2025 11:08:40 +0200 Subject: [PATCH 1/2] Add small pic to recipes and update the scehma.sql --- backend/__pycache__/db_utils.cpython-313.pyc | Bin 7844 -> 8018 bytes backend/__pycache__/main.cpython-313.pyc | Bin 6260 -> 6530 bytes backend/db_utils.py | 17 +++++++------ backend/main.py | 5 ++++ backend/schema.sql | 3 ++- frontend/src/assets/placeholder.svg | 25 +++++++++++++++++++ frontend/src/components/RecipeDetails.jsx | 10 ++++---- frontend/src/components/RecipeSearchList.jsx | 9 +++---- 8 files changed, 51 insertions(+), 18 deletions(-) create mode 100644 frontend/src/assets/placeholder.svg diff --git a/backend/__pycache__/db_utils.cpython-313.pyc b/backend/__pycache__/db_utils.cpython-313.pyc index 38fbbe10cc4d7f81ab63304437b55b0e2a44a527..ae58e1ea3cb6b736627b075c9e76caf5d3afbe37 100644 GIT binary patch delta 799 zcmZvZ&rj1}7{}kPt6hJNZKd0oLlPE6m=mSLFqA2+(HH{ z?~=q5ytI|GV*~1%oaCr?uqpYVsjl;>?1UT_V51FV6GNjTg(5dhQSF7WaGiprs7kIl zWm^g9Cz=b!#TJI^!y8t_WtyLQ2nosL54`-)Gk7go;FDFRIt-r6kA4pZpZgkHKIo_2 z*-$6WG;n2hFwBq&PekQOV#cr>^CpYz|ZpY;$A22&8L4_346QR`jKhG zr_R+FN61R|X+2JtgdpltoHuB;lw?t_AMqLi`YuHZUu$Fs)d9O+ok^nW9%#Ndlm=lT z0GuZYx>9lU6SyeW3Wu;X7CLG_v0Tp(i}=8$rVlxcsI9Q5rVi^}RSTFJ&OPZgTQHf& z?Qp^l325_2f|pRv;L2=O#g5?H$E3moe|CCX`Gd!DyO53KMm7z9vuU*1ME=jF<$z7| zzib#}6Vo-i#0L$Alr-LOu%#{*^*ZA<{InS(q>u^}9aJ|cp&sTczTYy8hRReNx{tm+ zWB=i@^UmbtxM_1U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_zDaRg;ILg{pz%xb#3qr*Q{|c(}D~qp7YLl z&(~i$cHNcpF0&DI81h3K3=GKZ&<$DunVuQXvbp-2A?I0U4{4kOh;fa9;VST9Kz@sE z*Fwnm&-j<+z%@SSUuGZIIDwVuZBJWUhz+dTJ$Zia4ULES9h-Y0GdHG*FxL!>)1MFK cGw+3OIf4Zvm~hhr8i&qf^ciohfd7cU0j@@)7ytkO delta 1694 zcmZuxOH3PA6n!(E8UF@l{%$-La3llp@AYk0Vz!pvX~*UWWai3goIMX zL@I%9O8dGXQk7;|x@p>Mx~keFn<`y^QdQAN{iy1OMb!aYNbGv=xTaCWNbkJ+?!CV6 z+>hU_bES4yv8u{J;Cu2xGV_n;Yu9xPmt#Fr9sAUBS-56TI6e_Bi92L8A+u>gVUL9n z7h=B(SGZo*DfWuL2w~d5*2TfeItW5T0HZr14dWq#a0a0kA&P(wv;iT85U&9Kx+nsy z6J4;CJ>o1X4b7pm&S#Wz?1c5y*!39aEJ76Fg*?72q~`W^=9&mhVZhC(=My zBRZM{Zt-ABLW% z2-^Lh01_PSW8b-FhKJxl-$ua1ptLTO@p_Q)X5Ff&Sv9XJ8V{$F8_UW{VaC9;#O6H- zu7PcNu5<0|*c1PM=vG;?w-ttN!h6G389H|4ZDV_0KP&ibtk35^k;iVzH$16 zDPh9Fe)cu8ao-tM?H{bi;+Ws0ebND?n4_oyQ3vzjCV-l8@4zVNuMA%Hu zPG!_!<8@KX(@c&Iu=(m&YQ|9=KHRaeqf)h*Z5y!mg{h1?R<1IJspRfqfP1kR>j%6)q9jNo0_MxeI8Jw%;of*wC}jR2Wh846X%t?e+JiLU5PsG List[Dict[str, Any]]: cur.execute( """ SELECT id, name, meal_type, time_minutes, - tags, ingredients, steps + tags, ingredients, steps, image FROM recipes ORDER BY id """ @@ -68,7 +68,7 @@ def list_recipes_db() -> List[Dict[str, Any]]: def update_recipe_db(recipe_id: int, recipe_data: Dict[str, Any]) -> Optional[Dict[str, Any]]: """ עדכון מתכון קיים לפי id. - recipe_data: name, meal_type, time_minutes, tags, ingredients, steps + recipe_data: name, meal_type, time_minutes, tags, ingredients, steps, image """ conn = get_conn() try: @@ -81,9 +81,10 @@ def update_recipe_db(recipe_id: int, recipe_data: Dict[str, Any]) -> Optional[Di time_minutes = %s, tags = %s, ingredients = %s, - steps = %s + steps = %s, + image = %s WHERE id = %s - RETURNING id, name, meal_type, time_minutes, tags, ingredients, steps + RETURNING id, name, meal_type, time_minutes, tags, ingredients, steps, image """, ( recipe_data["name"], @@ -92,6 +93,7 @@ def update_recipe_db(recipe_id: int, recipe_data: Dict[str, Any]) -> Optional[Di json.dumps(recipe_data.get("tags", [])), json.dumps(recipe_data.get("ingredients", [])), json.dumps(recipe_data.get("steps", [])), + recipe_data.get("image"), recipe_id, ), ) @@ -129,9 +131,9 @@ def create_recipe_db(recipe_data: Dict[str, Any]) -> Dict[str, Any]: with conn.cursor() as cur: cur.execute( """ - INSERT INTO recipes (name, meal_type, time_minutes, tags, ingredients, steps) - VALUES (%s, %s, %s, %s, %s, %s) - RETURNING id, name, meal_type, time_minutes, tags, ingredients, steps + INSERT INTO recipes (name, meal_type, time_minutes, tags, ingredients, steps, image) + VALUES (%s, %s, %s, %s, %s, %s, %s) + RETURNING id, name, meal_type, time_minutes, tags, ingredients, steps, image """, ( recipe_data["name"], @@ -140,6 +142,7 @@ def create_recipe_db(recipe_data: Dict[str, Any]) -> Dict[str, Any]: json.dumps(recipe_data.get("tags", [])), json.dumps(recipe_data.get("ingredients", [])), json.dumps(recipe_data.get("steps", [])), + recipe_data.get("image"), ), ) row = cur.fetchone() diff --git a/backend/main.py b/backend/main.py index edfc28f..6328b3c 100644 --- a/backend/main.py +++ b/backend/main.py @@ -24,6 +24,7 @@ class RecipeBase(BaseModel): tags: List[str] = [] ingredients: List[str] = [] steps: List[str] = [] + image: Optional[str] = None # Base64-encoded image or image URL class RecipeCreate(RecipeBase): @@ -65,6 +66,7 @@ def list_recipes(): tags=r["tags"] or [], ingredients=r["ingredients"] or [], steps=r["steps"] or [], + image=r.get("image"), ) for r in rows ] @@ -86,6 +88,7 @@ def create_recipe(recipe_in: RecipeCreate): tags=row["tags"] or [], ingredients=row["ingredients"] or [], steps=row["steps"] or [], + image=row.get("image"), ) @app.put("/recipes/{recipe_id}", response_model=Recipe) @@ -105,6 +108,7 @@ def update_recipe(recipe_id: int, recipe_in: RecipeUpdate): tags=row["tags"] or [], ingredients=row["ingredients"] or [], steps=row["steps"] or [], + image=row.get("image"), ) @@ -136,6 +140,7 @@ def random_recipe( tags=r["tags"] or [], ingredients=r["ingredients"] or [], steps=r["steps"] or [], + image=r.get("image"), ) for r in rows ] diff --git a/backend/schema.sql b/backend/schema.sql index 2e5c4dc..905d5c4 100644 --- a/backend/schema.sql +++ b/backend/schema.sql @@ -7,7 +7,8 @@ CREATE TABLE IF NOT EXISTS recipes ( tags JSONB NOT NULL DEFAULT '[]', -- ["מהיר", "בריא"] ingredients JSONB NOT NULL DEFAULT '[]', -- ["ביצה", "עגבניה", "מלח"] - steps JSONB NOT NULL DEFAULT '[]' -- ["לחתוך", "לבשל", ...] + steps JSONB NOT NULL DEFAULT '[]', -- ["לחתוך", "לבשל", ...] + image TEXT -- Base64-encoded image or image URL ); -- Optional: index for filters diff --git a/frontend/src/assets/placeholder.svg b/frontend/src/assets/placeholder.svg new file mode 100644 index 0000000..fbb594f --- /dev/null +++ b/frontend/src/assets/placeholder.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + No Image + \ No newline at end of file diff --git a/frontend/src/components/RecipeDetails.jsx b/frontend/src/components/RecipeDetails.jsx index cdfa816..5c0d00e 100644 --- a/frontend/src/components/RecipeDetails.jsx +++ b/frontend/src/components/RecipeDetails.jsx @@ -1,3 +1,5 @@ +import placeholderImage from "../assets/placeholder.svg"; + function RecipeDetails({ recipe, onEditClick, onDeleteClick, onShowDeleteModal }) { if (!recipe) { return ( @@ -14,11 +16,9 @@ function RecipeDetails({ recipe, onEditClick, onDeleteClick, onShowDeleteModal } return (
{/* Recipe Image */} - {recipe.image && ( -
- {recipe.name} -
- )} +
+ {recipe.name} +
diff --git a/frontend/src/components/RecipeSearchList.jsx b/frontend/src/components/RecipeSearchList.jsx index 231d4f8..55ca5f2 100644 --- a/frontend/src/components/RecipeSearchList.jsx +++ b/frontend/src/components/RecipeSearchList.jsx @@ -1,4 +1,5 @@ import { useState } from "react"; +import placeholderImage from "../assets/placeholder.svg"; function RecipeSearchList({ allRecipes, @@ -181,11 +182,9 @@ function RecipeSearchList({ } onClick={() => onSelect(r)} > - {r.image && ( -
- {r.name} -
- )} +
+ {r.name} +
{r.name}
From c8025dc62b64c8d58e4d17fffdbbc3a49abc1f78 Mon Sep 17 00:00:00 2001 From: dvirlabs Date: Fri, 5 Dec 2025 11:09:46 +0200 Subject: [PATCH 2/2] Add small pic to recipes and update the scehma.sql --- backend/__pycache__/db_utils.cpython-313.pyc | Bin 8018 -> 8018 bytes backend/__pycache__/main.cpython-313.pyc | Bin 6530 -> 6530 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/backend/__pycache__/db_utils.cpython-313.pyc b/backend/__pycache__/db_utils.cpython-313.pyc index ae58e1ea3cb6b736627b075c9e76caf5d3afbe37..35a823fefe72d3f042061cc8e9291abc8326f0dd 100644 GIT binary patch delta 19 Zcmca)cgc?HGcPX}0}vQ3+{oo24*)$(1vdZy delta 19 Zcmca)cgc?HGcPX}0}z