parent
cf5e7b3ddd
commit
dbd86b5a29
@ -0,0 +1,72 @@ |
||||
import React, { useState } from 'react'; |
||||
import { |
||||
Dialog, |
||||
DialogTitle, |
||||
DialogContent, |
||||
DialogActions, |
||||
Button, |
||||
Box, |
||||
} from '@mui/material'; |
||||
|
||||
import { recipeApi } from '../services/api'; |
||||
|
||||
import CloseIcon from '@mui/icons-material/Close'; |
||||
import { StuffNameAndAmount } from '../types/types'; |
||||
|
||||
const AddByRecipeDialog = async ({ |
||||
openDialog, |
||||
setOpenDialog, |
||||
recipeId |
||||
}: { |
||||
openDialog: boolean, |
||||
setOpenDialog: (open: boolean) => void, |
||||
recipeId: number, |
||||
}) => { |
||||
const recipe = await recipeApi.getById(recipeId); |
||||
|
||||
return ( |
||||
<Dialog open={openDialog} onClose={() => setOpenDialog(false)} disableScrollLock={true} PaperProps={{ sx: { minWidth: '300px', maxHeight: '80vh' } }}> |
||||
<DialogTitle sx={{ m: 0, p: 2, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}> |
||||
|
||||
買うものリストへ追加 |
||||
<CloseIcon |
||||
onClick={() => setOpenDialog(false)} |
||||
sx={{ |
||||
cursor: 'pointer', |
||||
color: (theme) => theme.palette.grey[500], |
||||
}} |
||||
/> |
||||
</DialogTitle> |
||||
<DialogContent dividers sx={{ padding: 2 }}> |
||||
<div> |
||||
<strong>レシピ名:</strong> {recipe.recipeName} |
||||
</div> |
||||
<div> |
||||
({recipe.maxservings}) |
||||
</div> |
||||
<div> |
||||
<strong>材料:</strong> |
||||
<ul> |
||||
{recipe.stuffNameAndAmountList.map((item, index) => ( |
||||
<li key={index}> |
||||
{item.stuffName} - {item.amount}個 |
||||
</li> |
||||
))} |
||||
</ul> |
||||
</div> |
||||
|
||||
{/* レシピを追加する人数分を入力 */} |
||||
|
||||
<div> |
||||
<strong>材料を買うものリストに追加します。</strong> |
||||
</div> |
||||
</DialogContent> |
||||
|
||||
<DialogActions> |
||||
<button onClick={() => setOpenDialog(false)}>閉じる</button> |
||||
</DialogActions> |
||||
</Dialog> |
||||
); |
||||
} |
||||
|
||||
export default AddByRecipeDialog; |
Loading…
Reference in new issue