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

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. 51
      frontend/src/pages/RecipeList.tsx

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

@ -282,8 +282,6 @@ const AddRecipe: React.FC = () => {
))}</List>)}
<div style={{ position: "fixed", left: "80%", transform: 'translateX(-50%)', bottom: "10%" }}>
<Box sx={{ textAlign: 'center' }}>
<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' }}>
<Button variant='contained' color="primary" onClick={handleSubmit} sx={{ marginRight: "1rem" }}>
<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>
</div>
@ -344,49 +338,6 @@ const AddRecipe: React.FC = () => {
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>
</>
}

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

Loading…
Cancel
Save