import React, { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { recipeApi } from '../services/api'; import { Container, Typography, Tooltip, List, ListItem, ListItemText, ListItemSecondaryAction, IconButton, Checkbox, Fab, Dialog, DialogTitle, DialogContent, DialogActions, TextField, Button, Box, FormControlLabel, FormGroup, MenuItem, Select, FormControl, InputLabel } from '@mui/material'; import { Add as AddIcon, Delete as DeleteIcon, ShoppingBasket as ShoppingBasketIcon, SoupKitchen as SoupKitchenIcon } from '@mui/icons-material'; import { ToBuy, Stuff, RecipeWithId, RecipeDetail } from '../types/types'; import { useMessage } from '../components/MessageContext'; const RecipeList: React.FC = () => { const navigate = useNavigate(); // 料理リストの料理名を格納する配列 const { showErrorMessage } = useMessage(); // すべての料理リスト const [allRecipes, setAllRecipes] = useState(); const openRecipeById = (recipeId: number) => { navigate('/addRecipe/' + recipeId); } const fetchAllRecipes = async () => { try { const recipes = await recipeApi.getAllRecipes(); setAllRecipes(recipes); } catch (error) { showErrorMessage("レシピの取得に失敗しました。"); // console.error(`${TASK_ERRORS.FETCH_FAILED}:`, error); } }; // コンポーネントマウント時にタスク一覧を取得 useEffect(() => { fetchAllRecipes(); }, []); return (

料理リスト

{/* */} {/* 料理一覧をマップして各タスクをリストアイテムとして表示 */} {!allRecipes ?

読み込み中...

: allRecipes.map((recipe, index) => ( // ))} {/*
*/}
); }; export default RecipeList;