diff --git a/frontend/src/pages/RecipeList.tsx b/frontend/src/pages/RecipeList.tsx index 08ec897..89ec4cc 100644 --- a/frontend/src/pages/RecipeList.tsx +++ b/frontend/src/pages/RecipeList.tsx @@ -27,7 +27,7 @@ import { InputLabel } from '@mui/material'; import { - Add as AddIcon, Delete as DeleteIcon, ShoppingBasket as ShoppingBasketIcon, + Add as AddIcon, Delete as DeleteIcon, Edit as EditIcon, ShoppingBasket as ShoppingBasketIcon, SoupKitchen as SoupKitchenIcon, Close as CloseIcon, TaskAlt as TaskAltIcon } from '@mui/icons-material'; import { ToBuy, Stuff, RecipeWithId, RecipeDetail } from '../types/types'; @@ -39,8 +39,14 @@ const RecipeList: React.FC = () => { const { showErrorMessage } = useMessage(); + const EMPTY_RECIPEWITHID = { + recipeName: '',// レシピ名 + summary: '',// レシピ概要 + recipeId: 0, // レシピID + maxServings: 0 // 最大調理可能数 + } // すべての料理リスト - const [allRecipes, setAllRecipes] = useState(); + const [allRecipes, setAllRecipes] = useState([EMPTY_RECIPEWITHID, EMPTY_RECIPEWITHID]); const openRecipeById = (recipeId: number) => { navigate('/addRecipe/' + recipeId); @@ -51,7 +57,7 @@ const RecipeList: React.FC = () => { const recipes = await recipeApi.getAllRecipes(); setAllRecipes(recipes); console.log("マックス"); - console.log(recipes.map(recipe => recipe.maxServings)) + console.log(allRecipes.map(recipe => recipe.maxServings)) } catch (error) { showErrorMessage("レシピの取得に失敗しました。"); // console.error(`${TASK_ERRORS.FETCH_FAILED}:`, error); @@ -92,7 +98,39 @@ const RecipeList: React.FC = () => { onClick={() => openRecipeById(recipe.recipeId)} > {recipe.recipeName} - {recipe.maxServings === 0 && } + {recipe.maxServings === 0 && + + { + navigate('/addRecipe/' + recipe.recipeId); + }} + > + + + + } + {recipe.maxServings !== 0 && + + {recipe.maxServings}人分 + + + {/* 買い物リスト:数量変更ボタン */} + + { + navigate('/addRecipe/' + recipe.recipeId); + }} + > + + + + + } // @@ -100,7 +138,19 @@ const RecipeList: React.FC = () => { {/* */}
- + */}