stockpageを編集しました

feature-backend-add-springdocs
Yuna.Suzuki 5 months ago
parent 7a0bc34eb0
commit 978c0ad42b
  1. 202
      frontend/src/pages/StockPage.tsx

@ -97,7 +97,7 @@ const StockPage: React.FC = () => {
alert("削除する食材を選択してください。");
}
};
/** 編集ダイアログを閉じる */
/** 削除ダイアログを閉じる */
const handleCloseDelete = () => {
setIsDeleteOpen(false);
};
@ -109,34 +109,57 @@ const StockPage: React.FC = () => {
if (filteredStocks.length === 0) return null;
return (
<TableContainer component={Paper}>
<Table>
<TableHead sx={{ backgroundColor: "#dcdcdc", color: "#333" }}>
<TableRow>
<TableCell></TableCell>
<TableCell></TableCell>
<TableCell></TableCell>
<TableCell></TableCell>
<TableCell></TableCell>
</TableRow>
</TableHead>
<TableBody>
{filteredStocks.map(stock => (
<TableRow
key={stock.stock_id}
onClick={() => handleRowClick(stock)}
style={{ backgroundColor: selectedRow?.stock_id === stock.stock_id ? "yellow" : "white", cursor: "pointer" }}
>
<TableCell>{stock.stuff_name}</TableCell>
<TableCell>{stock.amount}</TableCell>
<TableCell>{stock.price}</TableCell>
<TableCell>{formatDate(stock.exp_date)}</TableCell>
<TableCell>{formatDate(stock.buy_date)}</TableCell>
<>
<TableContainer component={Paper}>
<Table>
<TableHead sx={{ backgroundColor: "#dcdcdc", color: "#333" }}>
<TableRow>
<TableCell></TableCell>
<TableCell></TableCell>
<TableCell></TableCell>
<TableCell></TableCell>
<TableCell></TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
</TableHead>
<TableBody>
{filteredStocks.map(stock => (
<TableRow
key={stock.stock_id}
onClick={() => handleRowClick(stock)}
style={{ backgroundColor: selectedRow?.stock_id === stock.stock_id ? "yellow" : "white", cursor: "pointer" }}
>
<TableCell>{stock.stuff_name}</TableCell>
<TableCell>{stock.amount}</TableCell>
<TableCell>{stock.price}</TableCell>
<TableCell>{formatDate(stock.exp_date)}</TableCell>
<TableCell>{formatDate(stock.buy_date)}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
{/* 編集ダイアログ */}
<Dialog open={isEditOpen} onClose={handleCloseEdit} fullWidth maxWidth="sm">
<DialogTitle></DialogTitle>
<DialogContent>
{selectedRow && (
<>
<Typography variant="body1"></Typography>
<TextField label="食材名" fullWidth margin="normal" defaultValue={selectedRow.stuff_name} />
<TextField label="数量" fullWidth margin="normal" defaultValue={selectedRow.amount} />
<TextField label="購入価格" fullWidth margin="normal" defaultValue={selectedRow.price} />
<TextField label="賞味・消費期限" fullWidth margin="normal" defaultValue={selectedRow.exp_date} />
<TextField label="購入日" fullWidth margin="normal" defaultValue={selectedRow.buy_date} />
<Button onClick={() => setIsEditOpen(false)} sx={{ mt: 3, mb: 2, left: '68%' }}></Button>
<Button variant="contained" color="success" onClick={handleCloseEdit} sx={{ mt: 3, mb: 2, left: "68%" }}>
</Button>
</>
)}
</DialogContent>
</Dialog>
</>
);
};
@ -148,18 +171,24 @@ const StockPage: React.FC = () => {
</Typography>
{/* タスク編集ボタン(全テーブル共通) */}
<Button variant="contained" color="success" onClick={handleOpenEdit} sx={{ mt: 3, mb: 2, left: '80%' }}>
</Button>
<Button variant="contained" color="success" onClick={handleOpenEdit} sx={{ mt: 3, mb: 2, left: '80%' }}>
</Button>
{/* タスク削除ボタン */}
<Button variant="contained" color="error" onClick={handleOpenDelete} sx={{ mt: 3, mb: 2, left: '82%' }}></Button>
<Dialog open={isDeleteOpen} onClose={handleCloseDelete}>
<Dialog open={isDeleteOpen}
onClose={handleCloseDelete}
fullWidth
maxWidth="sm"
sx={{ overflow: "hidden" }}
>
<DialogTitle></DialogTitle>
<DialogContent>
<Typography variant="body1"></Typography>
<Typography variant="body2" color="error"> 注意: 削除すると復元できません</Typography>
<Button variant="contained" color="error" onClick={handleCloseDelete} style={{ marginTop: "10px" }} sx={{ mt: 3, mb: 2, left: '85%' }}></Button>
<Button onClick={() => setIsDeleteOpen(false)} sx={{ mt: 3, mb: 2, left: '70%' }}></Button>
<Button variant="contained" color="error" onClick={handleCloseDelete} style={{ marginTop: "10px" }} sx={{ mt: 3, mb: 2, left: '72%' }}></Button>
</DialogContent>
</Dialog>
@ -168,135 +197,30 @@ const StockPage: React.FC = () => {
<Typography variant="h4" component="h1" gutterBottom></Typography>
<div style={{ border: '3px solid black', borderRadius: '8px', backgroundColor: '#add8e6', height: 'auto', padding: '20px', marginBottom: "20px" }}>
{StockTable(stocks, ["乳製品"])}
{/* 編集ダイアログ */}
<Dialog open={isEditOpen} onClose={handleCloseEdit} fullWidth maxWidth="sm">
<DialogTitle></DialogTitle>
<DialogContent>
{selectedRow && (
<>
<Typography variant="body1"></Typography>
<TextField label="食材名" fullWidth margin="normal" defaultValue={selectedRow.stuff_name} />
<TextField label="数量" fullWidth margin="normal" defaultValue={selectedRow.amount} />
<TextField label="購入価格" fullWidth margin="normal" defaultValue={selectedRow.price} />
<TextField label="賞味・消費期限" fullWidth margin="normal" defaultValue={selectedRow.exp_date} />
<TextField label="購入日" fullWidth margin="normal" defaultValue={selectedRow.buy_date} />
<Button variant="contained" color="success" onClick={handleCloseEdit} sx={{ mt: 3, mb: 2, left: '82%' }}>
</Button>
</>
)}
</DialogContent>
</Dialog>
</div>
{/* 肉・魚 */}
<Typography variant="h4" component="h1" gutterBottom></Typography>
<div style={{ border: '3px solid black', borderRadius: '8px', backgroundColor: '#add8e6', height: 'auto', padding: '20px', marginBottom: "20px" }}>
{StockTable(stocks, ["肉", "魚"])}
{/* 編集ダイアログ */}
<Dialog open={isEditOpen} onClose={handleCloseEdit} fullWidth maxWidth="sm">
<DialogTitle></DialogTitle>
<DialogContent>
{selectedRow && (
<>
<Typography variant="body1"></Typography>
<TextField label="食材名" fullWidth margin="normal" defaultValue={selectedRow.stuff_name} />
<TextField label="数量" fullWidth margin="normal" defaultValue={selectedRow.amount} />
<TextField label="購入価格" fullWidth margin="normal" defaultValue={selectedRow.price} />
<TextField label="賞味・消費期限" fullWidth margin="normal" defaultValue={selectedRow.exp_date} />
<TextField label="購入日" fullWidth margin="normal" defaultValue={selectedRow.buy_date} />
<Button variant="contained" color="success" onClick={handleCloseEdit} sx={{ mt: 3, mb: 2, left: '82%'}}>
</Button>
</>
)}
</DialogContent>
</Dialog>
{StockTable(stocks, ["肉", "魚"])}
</div>
{/* 野菜 */}
<Typography variant="h4" component="h1" gutterBottom></Typography>
<div style={{ border: '3px solid black', borderRadius: '8px', backgroundColor: '#add8e6', height: 'auto', padding: '20px', marginBottom: "20px" }}>
{StockTable(stocks, ["野菜"])}
{/* 編集ダイアログ */}
<Dialog open={isEditOpen} onClose={handleCloseEdit} fullWidth maxWidth="sm">
<DialogTitle></DialogTitle>
<DialogContent>
{selectedRow && (
<>
<Typography variant="body1"></Typography>
<TextField label="食材名" fullWidth margin="normal" defaultValue={selectedRow.stuff_name} />
<TextField label="数量" fullWidth margin="normal" defaultValue={selectedRow.amount} />
<TextField label="購入価格" fullWidth margin="normal" defaultValue={selectedRow.price} />
<TextField label="賞味・消費期限" fullWidth margin="normal" defaultValue={selectedRow.exp_date} />
<TextField label="購入日" fullWidth margin="normal" defaultValue={selectedRow.buy_date} />
<Button variant="contained" color="success" onClick={handleCloseEdit} sx={{ mt: 3, mb: 2, left: '82%' }}>
</Button>
</>
)}
</DialogContent>
</Dialog>
</div>
{/* 調味料 */}
<Typography variant="h4" component="h1" gutterBottom>調</Typography>
<div style={{ border: '3px solid black', borderRadius: '8px', backgroundColor: '#add8e6', height: 'auto', padding: '20px', marginBottom: "20px" }}>
{StockTable(stocks, ["調味料"])}
{/* 編集ダイアログ */}
<Dialog open={isEditOpen} onClose={handleCloseEdit} fullWidth maxWidth="sm">
<DialogTitle></DialogTitle>
<DialogContent>
{selectedRow && (
<>
<Typography variant="body1"></Typography>
<TextField label="食材名" fullWidth margin="normal" defaultValue={selectedRow.stuff_name} />
<TextField label="数量" fullWidth margin="normal" defaultValue={selectedRow.amount} />
<TextField label="購入価格" fullWidth margin="normal" defaultValue={selectedRow.price} />
<TextField label="賞味・消費期限" fullWidth margin="normal" defaultValue={selectedRow.exp_date} />
<TextField label="購入日" fullWidth margin="normal" defaultValue={selectedRow.buy_date} />
<Button variant="contained" color="success" onClick={handleCloseEdit} sx={{ mt: 3, mb: 2, left: '82%' }}>
</Button>
</>
)}
</DialogContent>
</Dialog>
</div>
{/* その他 */}
<Typography variant="h4" component="h1" gutterBottom></Typography>
<div style={{ border: '3px solid black', borderRadius: '8px', backgroundColor: '#add8e6', height: 'auto', padding: '20px', marginBottom: "20px" }}>
{StockTable(stocks, ["その他"])}
{/* 編集ダイアログ */}
<Dialog open={isEditOpen} onClose={handleCloseEdit} fullWidth maxWidth="sm">
<DialogTitle></DialogTitle>
<DialogContent>
{selectedRow && (
<>
<Typography variant="body1"></Typography>
<TextField label="食材名" fullWidth margin="normal" defaultValue={selectedRow.stuff_name} />
<TextField label="数量" fullWidth margin="normal" defaultValue={selectedRow.amount} />
<TextField label="購入価格" fullWidth margin="normal" defaultValue={selectedRow.price} />
<TextField label="賞味・消費期限" fullWidth margin="normal" defaultValue={selectedRow.exp_date} />
<TextField label="購入日" fullWidth margin="normal" defaultValue={selectedRow.buy_date} />
<Button variant="contained" color="success" onClick={handleCloseEdit} sx={{ mt: 3, mb: 2, left: '82%' }}>
</Button>
</>
)}
</DialogContent>
</Dialog>
</div>
</Container>
);

Loading…
Cancel
Save