新しい料理を追加ボタンのUI変更、用意できる人数によって表示内容を変更

feature_frontend_dishList_ui
masato.fujita 4 months ago
parent c490af7489
commit cf5e7b3ddd
  1. 62
      frontend/src/pages/RecipeList.tsx

@ -27,7 +27,7 @@ import {
InputLabel InputLabel
} from '@mui/material'; } from '@mui/material';
import { 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 SoupKitchen as SoupKitchenIcon, Close as CloseIcon, TaskAlt as TaskAltIcon
} from '@mui/icons-material'; } from '@mui/icons-material';
import { ToBuy, Stuff, RecipeWithId, RecipeDetail } from '../types/types'; import { ToBuy, Stuff, RecipeWithId, RecipeDetail } from '../types/types';
@ -39,8 +39,14 @@ const RecipeList: React.FC = () => {
const { showErrorMessage } = useMessage(); const { showErrorMessage } = useMessage();
const EMPTY_RECIPEWITHID = {
recipeName: '',// レシピ名
summary: '',// レシピ概要
recipeId: 0, // レシピID
maxServings: 0 // 最大調理可能数
}
// すべての料理リスト // すべての料理リスト
const [allRecipes, setAllRecipes] = useState<RecipeWithId[]>(); const [allRecipes, setAllRecipes] = useState<RecipeWithId[]>([EMPTY_RECIPEWITHID, EMPTY_RECIPEWITHID]);
const openRecipeById = (recipeId: number) => { const openRecipeById = (recipeId: number) => {
navigate('/addRecipe/' + recipeId); navigate('/addRecipe/' + recipeId);
@ -51,7 +57,7 @@ const RecipeList: React.FC = () => {
const recipes = await recipeApi.getAllRecipes(); const recipes = await recipeApi.getAllRecipes();
setAllRecipes(recipes); setAllRecipes(recipes);
console.log("マックス"); console.log("マックス");
console.log(recipes.map(recipe => recipe.maxServings)) console.log(allRecipes.map(recipe => recipe.maxServings))
} catch (error) { } catch (error) {
showErrorMessage("レシピの取得に失敗しました。"); showErrorMessage("レシピの取得に失敗しました。");
// console.error(`${TASK_ERRORS.FETCH_FAILED}:`, error); // console.error(`${TASK_ERRORS.FETCH_FAILED}:`, error);
@ -92,7 +98,39 @@ const RecipeList: React.FC = () => {
onClick={() => openRecipeById(recipe.recipeId)} onClick={() => openRecipeById(recipe.recipeId)}
> >
{recipe.recipeName} {recipe.recipeName}
{recipe.maxServings === 0 && <CloseIcon />} {recipe.maxServings === 0 && <FormGroup row><CloseIcon
style={{fontSize:"3vw", position: "absolute", right:'10%', transform: 'translateY(-50%)', color: "tomato"}}
/>
<Tooltip title="編集">
<IconButton sx={{ position: "absolute", right:'3%', transform: 'translateY(-50%)' }} edge="end" aria-label="編集"
onClick={() => {
navigate('/addRecipe/' + recipe.recipeId);
}}
>
<EditIcon style={{fontSize:"2.5vw"}}/>
</IconButton>
</Tooltip>
</FormGroup>}
{recipe.maxServings !== 0 && <FormGroup row>
<text style={{
fontSize:"2vw", position: "absolute", right:'18%', transform: 'translateY(-52%)', color: "mediumaquamarine"}}>
{recipe.maxServings}
</text>
<TaskAltIcon style={{
fontSize:"3vw", position: "absolute", right:'10%', transform: 'translateY(-50%)', color: "mediumaquamarine"}}
/>
{/* 買い物リスト:数量変更ボタン */}
<Tooltip title="編集">
<IconButton sx={{ position: "absolute", right:'3%', transform: 'translateY(-50%)' }} edge="end" aria-label="編集"
onClick={() => {
navigate('/addRecipe/' + recipe.recipeId);
}}
>
<EditIcon style={{fontSize:"2.5vw"}}/>
</IconButton>
</Tooltip>
</FormGroup>
}
</Button> </Button>
</FormGroup> </FormGroup>
// </ListItem> // </ListItem>
@ -100,7 +138,19 @@ const RecipeList: React.FC = () => {
{/* </List> */} {/* </List> */}
</div> </div>
<div style={{ width: "100%", position: "fixed", left: "50%", transform: 'translateX(-50%)', bottom: "64px" }}> <div style={{ width: "100%", position: "fixed", left: "50%", transform: 'translateX(-50%)', bottom: "64px" }}>
<Button variant='contained' sx={{ <Box sx={{ textAlign: 'center', position: 'fixed', bottom: 66, left: '80%', transform: 'translateX(-50%)' }}>
<Typography variant="caption" color="textSecondary">
</Typography>
</Box>
<Fab
color="primary"
sx={{ position: 'fixed', bottom: 90, left: '80%', transform: 'translateX(-50%)' }}
onClick={() => navigate('/addRecipe')}
>
<AddIcon />
</Fab>
{/* <Button variant='contained' sx={{
width: "60%", height: "60px", width: "60%", height: "60px",
fontSize: "32px", left: "50%", transform: 'translateX(-50%)' fontSize: "32px", left: "50%", transform: 'translateX(-50%)'
}} }}
@ -108,7 +158,7 @@ const RecipeList: React.FC = () => {
onClick={() => navigate('/addRecipe')} onClick={() => navigate('/addRecipe')}
> >
</Button> </Button> */}
</div> </div>
</Box> </Box>

Loading…
Cancel
Save