Merge remote-tracking branch 'origin/dev-frontend-stock' into dev-frontend-在庫登録

dev-frontend-stock
akito.nishiwaki 5 months ago
commit 8d0cb88d7f
  1. 62
      frontend/src/pages/StockPage.tsx

@ -9,6 +9,8 @@ import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Paper
import { import {
Container, Container,
Typography, Typography,
Tooltip,
Fab,
Dialog, Dialog,
DialogTitle, DialogTitle,
DialogContent, DialogContent,
@ -24,8 +26,15 @@ import CategoryDropDown from "../components/CategoryDropDown";
const StockPage: React.FC = () => { const StockPage: React.FC = () => {
const [stocks, setStocks] = useState<Stock[]>([]); const [stocks, setStocks] = useState<Stock[]>([]);
// 在庫編集ダイアログの表示状態 // 削除メッセージダイアログの表示状態
const [openDialog, setOpenDialog] = useState(false); const [open, setOpen] = useState(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);
// セル選択の表示状態
const [selectedRow, setSelectedRow] = useState<number | null>(null);
// コンポーネントマウント時にタスク一覧を取得 // コンポーネントマウント時にタスク一覧を取得
useEffect(() => { useEffect(() => {
@ -64,6 +73,14 @@ const StockPage: React.FC = () => {
}; };
*/ */
/**
*
*/
const handleRowClick = (id: number) => {
setSelectedRow(prevSelected => (prevSelected === id ? null : id)); // クリックで選択・解除を切り替え
};
return ( return (
<Container> <Container>
<Typography variant="h4" component="h1" gutterBottom> <Typography variant="h4" component="h1" gutterBottom>
@ -80,13 +97,24 @@ const StockPage: React.FC = () => {
</Button> </Button>
{/* タスク削除ボタン */} {/* タスク削除ボタン */}
<Button color="error" {/* <Button color="error"
type="submit" type="submit"
variant="contained" variant="contained"
sx={{ mt: 3, mb: 2, left: '82%' }} sx={{ mt: 3, mb: 2, left: '82%' }}
onClick={() => setOpenDialog(true)}
> >
</Button> </Button> */}
<Button variant="contained" color="error" onClick={handleOpen} sx={{ mt: 3, mb: 2, left: '82%' }}></Button>
<Dialog open={open} onClose={handleClose}>
<DialogTitle></DialogTitle>
<DialogContent>
<Typography variant="body1"></Typography>
<Typography variant="body2" color="error"> 注意: 削除すると復元できません</Typography>
<Button variant="contained" color="error" onClick={handleClose} style={{ marginTop: "10px" }} sx={{ mt: 3, mb: 2, left: '85%' }}></Button>
</DialogContent>
</Dialog>
<Typography variant="h4" component="h1" gutterBottom> <Typography variant="h4" component="h1" gutterBottom>
@ -111,8 +139,10 @@ const StockPage: React.FC = () => {
{stocks {stocks
.filter(stock => stock.category == "乳製品") // 乳製品だけ抽出 .filter(stock => stock.category == "乳製品") // 乳製品だけ抽出
.map(stock => ( .map(stock => (
<TableRow key={stock.stock_id} <TableRow
> key={stock.stock_id}
onClick={() => handleRowClick(stock.stock_id)}
style={{ backgroundColor: selectedRow === stock.stock_id ? "yellow" : "white", cursor: "pointer" }}>
<TableCell>{stock.stuff_name}</TableCell> <TableCell>{stock.stuff_name}</TableCell>
<TableCell>{stock.amount}</TableCell> <TableCell>{stock.amount}</TableCell>
<TableCell>{stock.price}</TableCell> <TableCell>{stock.price}</TableCell>
@ -148,7 +178,10 @@ const StockPage: React.FC = () => {
{stocks {stocks
.filter(stock => stock.category == "肉" || stock.category == "魚") // 肉と魚だけ抽出 .filter(stock => stock.category == "肉" || stock.category == "魚") // 肉と魚だけ抽出
.map(stock => ( .map(stock => (
<TableRow key={stock.stock_id}> <TableRow
key={stock.stock_id}
onClick={() => handleRowClick(stock.stock_id)}
style={{ backgroundColor: selectedRow === stock.stock_id ? "yellow" : "white", cursor: "pointer" }}>
<TableCell>{stock.stuff_name}</TableCell> <TableCell>{stock.stuff_name}</TableCell>
<TableCell>{stock.amount}</TableCell> <TableCell>{stock.amount}</TableCell>
<TableCell>{stock.price}</TableCell> <TableCell>{stock.price}</TableCell>
@ -184,7 +217,10 @@ const StockPage: React.FC = () => {
{stocks {stocks
.filter(stock => stock.category == "野菜") // 野菜だけ抽出 .filter(stock => stock.category == "野菜") // 野菜だけ抽出
.map(stock => ( .map(stock => (
<TableRow key={stock.stock_id}> <TableRow
key={stock.stock_id}
onClick={() => handleRowClick(stock.stock_id)}
style={{ backgroundColor: selectedRow === stock.stock_id ? "yellow" : "white", cursor: "pointer" }}>
<TableCell>{stock.stuff_name}</TableCell> <TableCell>{stock.stuff_name}</TableCell>
<TableCell>{stock.amount}</TableCell> <TableCell>{stock.amount}</TableCell>
<TableCell>{stock.price}</TableCell> <TableCell>{stock.price}</TableCell>
@ -219,7 +255,10 @@ const StockPage: React.FC = () => {
{stocks {stocks
.filter(stock => stock.category == "調味料") // 調味料だけ抽出 .filter(stock => stock.category == "調味料") // 調味料だけ抽出
.map(stock => ( .map(stock => (
<TableRow key={stock.stock_id}> <TableRow
key={stock.stock_id}
onClick={() => handleRowClick(stock.stock_id)}
style={{ backgroundColor: selectedRow === stock.stock_id ? "yellow" : "white", cursor: "pointer" }}>
<TableCell>{stock.stuff_name}</TableCell> <TableCell>{stock.stuff_name}</TableCell>
<TableCell>{stock.amount}</TableCell> <TableCell>{stock.amount}</TableCell>
<TableCell>{stock.price}</TableCell> <TableCell>{stock.price}</TableCell>
@ -254,7 +293,10 @@ const StockPage: React.FC = () => {
{stocks {stocks
.filter(stock => stock.category == "その他") // その他だけ抽出 .filter(stock => stock.category == "その他") // その他だけ抽出
.map(stock => ( .map(stock => (
<TableRow key={stock.stock_id}> <TableRow
key={stock.stock_id}
onClick={() => handleRowClick(stock.stock_id)}
style={{ backgroundColor: selectedRow === stock.stock_id ? "yellow" : "white", cursor: "pointer" }}>
<TableCell>{stock.stuff_name}</TableCell> <TableCell>{stock.stuff_name}</TableCell>
<TableCell>{stock.amount}</TableCell> <TableCell>{stock.amount}</TableCell>
<TableCell>{stock.price}</TableCell> <TableCell>{stock.price}</TableCell>

Loading…
Cancel
Save