レシピ一覧・編集画面の修正

feature-dishuiandcolor^2
Masaharu.Kato 4 months ago
parent 7ec94b45f2
commit c4fb41e321
  1. 4
      frontend/src/components/AddByRecipeDialog.tsx
  2. 51
      frontend/src/pages/AddRecipe.tsx
  3. 61
      frontend/src/pages/RecipeList.tsx

@ -41,7 +41,7 @@ const AddByRecipeDialog = async ({
<div> <div>
<strong>:</strong> {recipe.recipeName} <strong>:</strong> {recipe.recipeName}
</div> </div>
<div> {/* <div>
({recipe.maxservings}) ({recipe.maxservings})
</div> </div>
<div> <div>
@ -53,7 +53,7 @@ const AddByRecipeDialog = async ({
</li> </li>
))} ))}
</ul> </ul>
</div> </div> */}
{/* レシピを追加する人数分を入力 */} {/* レシピを追加する人数分を入力 */}

@ -282,8 +282,6 @@ const AddRecipe: React.FC = () => {
))}</List>)} ))}</List>)}
<div style={{ position: "fixed", left: "80%", transform: 'translateX(-50%)', bottom: "10%" }}> <div style={{ position: "fixed", left: "80%", transform: 'translateX(-50%)', bottom: "10%" }}>
<Box sx={{ textAlign: 'center' }}> <Box sx={{ textAlign: 'center' }}>
<Typography variant="caption"></Typography> <Typography variant="caption"></Typography>
@ -296,11 +294,7 @@ const AddRecipe: React.FC = () => {
<div style={{ position: "fixed", left: "50%", transform: 'translateX(-50%)', bottom: "64px", whiteSpace: 'nowrap' }}> <div style={{ position: "fixed", left: "50%", transform: 'translateX(-50%)', bottom: "64px", whiteSpace: 'nowrap' }}>
<Button variant='contained' color="primary" onClick={handleSubmit} sx={{ marginRight: "1rem" }}> <Button variant='contained' color="primary" onClick={handleSubmit} sx={{ marginRight: "1rem" }}>
<SaveIcon sx={{ fontSize: "1.5rem", marginRight: "0.5rem" }} /> <SaveIcon sx={{ fontSize: "1.5rem", marginRight: "0.5rem" }} />
</Button>
<Button variant='contained' color="primary" onClick={openNumOfPeopleDialog}>
<ListAltIcon sx={{ fontSize: "1.5rem", marginRight: "0.5rem" }} />
</Button> </Button>
</div> </div>
@ -344,49 +338,6 @@ const AddRecipe: React.FC = () => {
setOpenAmountDialog(false); setOpenAmountDialog(false);
}} /> }} />
{/* 人数入力ダイアログ */}
<Dialog open={openNumOfPeapleDialog} onClose={() => setOpenNumOfPeapleDialog(false)} disableScrollLock={true}
style={{ width : '100%', position : 'fixed', left: '50%', transform: 'translateX(-50%)' }}
>
<Box display="flex" alignItems="center"
>
<DialogTitle sx={{ flexGrow: 1 }}></DialogTitle>
</Box>
<DialogContent>
<div>
{/* 人数入力フィールド */}
<TextField
margin="dense"
label="何人前"
fullWidth
value={numOfPeaple}
onChange={(e) => {
const value = e.target.value;
const parsedValue = parseInt(value, 10); // 数値に変換
if (/*!isNaN(parsedValue) && */ isNaN(parsedValue) || parsedValue >= 1) { //負数除外
setNumOfPeaple(parsedValue); // number型で保存
}
}}
sx={{ minWidth: "8px", width: "100%" }}
type="number"
inputProps={{ inputMode: "numeric", pattern: "[0-9]*" }} // ここで整数のみ許可
/>
</div>
<FormControlLabel
control={<Checkbox checked={checked} onChange={(e) => setChecked(e.target.checked)} />}
label={<Typography sx={{ fontSize: '85%' }}></Typography>}
/>
</DialogContent>
<DialogActions>
<Button onClick={() => setOpenNumOfPeapleDialog(false)}></Button>
<Button onClick={() => handleSubmitAndAddToBuy()} variant="contained"
style={{ width: '40%' }}
>
</Button>
</DialogActions>
</Dialog>
</div> </div>
</> </>
} }

@ -62,12 +62,12 @@ const RecipeList: React.FC = () => {
const fetchAllRecipes = async () => { const fetchAllRecipes = async () => {
try { try {
const recipes = await recipeApi.getAllRecipes(); const recipes = await recipeApi.getAllRecipes();
console.log('All recipes:');
console.log(recipes);
setAllRecipes(recipes); setAllRecipes(recipes);
console.log("マックス");
console.log(allRecipes.map(recipe => recipe.maxServings))
} catch (error) { } catch (error) {
console.error(`${RECIPE_ERRORS.FETCH_FAILED}:`, error);
showErrorMessage(RECIPE_ERRORS.FETCH_FAILED); showErrorMessage(RECIPE_ERRORS.FETCH_FAILED);
// console.error(`${TASK_ERRORS.FETCH_FAILED}:`, error);
} }
}; };
@ -105,33 +105,42 @@ const RecipeList: React.FC = () => {
} }
} }
> >
{recipe.recipeName} <ListItemText
{recipe.maxServings === 0 ? primary={recipe.recipeName}
<FormGroup row> />
<CloseIcon sx={{ fontSize: "3vw", position: "absolute", right: '10%', transform: 'translateY(-50%)', color: "tomato" }} />
</FormGroup> : <ListItemSecondaryAction>
<FormGroup row>
<text style={{ {recipe.maxServings ?
fontSize: "2vw", position: "absolute", right: '18%', transform: 'translateY(-52%)', color: "mediumaquamarine" <Typography variant="body1" component="span" sx={{ marginRight: '1em', color: "mediumaquamarine" }}>
}}>
{recipe.maxServings} {recipe.maxServings}
</text> </Typography>
<TaskAltIcon style={{ : <></>}
fontSize: "3vw", position: "absolute", right: '10%', transform: 'translateY(-50%)', color: "mediumaquamarine"
}}
/>
<Tooltip title="編集"> {recipe.maxServings === 0 ?
<IconButton sx={{ position: "absolute", right: '3%', transform: 'translateY(-50%)' }} edge="end" aria-label="編集" <Tooltip title="" sx={{ color: "tomato" }}>
onClick={() => { <IconButton edge="end" aria-label="">
navigate('/addRecipe/' + recipe.recipeId); <CloseIcon />
}} </IconButton>
> </Tooltip> :
<EditIcon style={{ fontSize: "2.5vw" }} /> <Tooltip title="" sx={{ color: "mediumaquamarine" }}>
<IconButton edge="end" aria-label="">
<TaskAltIcon />
</IconButton> </IconButton>
</Tooltip> </Tooltip>
</FormGroup> }
}
<Tooltip title="編集">
<IconButton edge="end" aria-label="編集"
onClick={() => {
navigate('/addRecipe/' + recipe.recipeId);
}}
>
<EditIcon />
</IconButton>
</Tooltip>
</ListItemSecondaryAction>
</ListItem> </ListItem>
))} ))}
</List> </List>

Loading…
Cancel
Save