From b52b88b7dbb3ea2d94ceaf79939b0d65e0e4a407 Mon Sep 17 00:00:00 2001 From: "Yuna.Suzuki" Date: Fri, 6 Jun 2025 09:51:11 +0900 Subject: [PATCH] =?UTF-8?q?StockPage=E3=82=92=E7=B7=A8=E9=9B=86=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/StockPage.tsx | 62 ++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/frontend/src/pages/StockPage.tsx b/frontend/src/pages/StockPage.tsx index e305d3b..1c8ee61 100644 --- a/frontend/src/pages/StockPage.tsx +++ b/frontend/src/pages/StockPage.tsx @@ -9,6 +9,8 @@ import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Paper import { Container, Typography, + Tooltip, + Fab, Dialog, DialogTitle, DialogContent, @@ -24,8 +26,15 @@ import CategoryDropDown from "../components/CategoryDropDown"; const StockPage: React.FC = () => { const [stocks, setStocks] = useState([]); - // 在庫編集ダイアログの表示状態 - const [openDialog, setOpenDialog] = useState(false); + // 削除メッセージダイアログの表示状態 + const [open, setOpen] = useState(false); + + const handleOpen = () => setOpen(true); + const handleClose = () => setOpen(false); + + + // セル選択の表示状態 + const [selectedRow, setSelectedRow] = useState(null); // コンポーネントマウント時にタスク一覧を取得 useEffect(() => { @@ -64,6 +73,14 @@ const StockPage: React.FC = () => { }; */ + /** + * セルを選択する関数 + */ + const handleRowClick = (id: number) => { + setSelectedRow(prevSelected => (prevSelected === id ? null : id)); // クリックで選択・解除を切り替え + }; + + return ( @@ -80,13 +97,24 @@ const StockPage: React.FC = () => { {/* タスク削除ボタン */} - + */} + + + + 食材の削除 + + この操作は取り消せません。本当に削除しますか? + ⚠️ 注意: 削除すると復元できません。 + + + 乳製品 @@ -111,8 +139,10 @@ const StockPage: React.FC = () => { {stocks .filter(stock => stock.category == "乳製品") // 乳製品だけ抽出 .map(stock => ( - + handleRowClick(stock.stock_id)} + style={{ backgroundColor: selectedRow === stock.stock_id ? "yellow" : "white", cursor: "pointer" }}> {stock.stuff_name} {stock.amount} {stock.price} @@ -148,7 +178,10 @@ const StockPage: React.FC = () => { {stocks .filter(stock => stock.category == "肉" || stock.category == "魚") // 肉と魚だけ抽出 .map(stock => ( - + handleRowClick(stock.stock_id)} + style={{ backgroundColor: selectedRow === stock.stock_id ? "yellow" : "white", cursor: "pointer" }}> {stock.stuff_name} {stock.amount} {stock.price} @@ -184,7 +217,10 @@ const StockPage: React.FC = () => { {stocks .filter(stock => stock.category == "野菜") // 野菜だけ抽出 .map(stock => ( - + handleRowClick(stock.stock_id)} + style={{ backgroundColor: selectedRow === stock.stock_id ? "yellow" : "white", cursor: "pointer" }}> {stock.stuff_name} {stock.amount} {stock.price} @@ -219,7 +255,10 @@ const StockPage: React.FC = () => { {stocks .filter(stock => stock.category == "調味料") // 調味料だけ抽出 .map(stock => ( - + handleRowClick(stock.stock_id)} + style={{ backgroundColor: selectedRow === stock.stock_id ? "yellow" : "white", cursor: "pointer" }}> {stock.stuff_name} {stock.amount} {stock.price} @@ -254,7 +293,10 @@ const StockPage: React.FC = () => { {stocks .filter(stock => stock.category == "その他") // その他だけ抽出 .map(stock => ( - + handleRowClick(stock.stock_id)} + style={{ backgroundColor: selectedRow === stock.stock_id ? "yellow" : "white", cursor: "pointer" }}> {stock.stuff_name} {stock.amount} {stock.price}