From c790bebb929f027235f4624ef626ead89df2da3e Mon Sep 17 00:00:00 2001 From: "Masaharu.Kato" Date: Thu, 19 Jun 2025 15:24:52 +0900 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E5=BA=AB=E8=BF=BD=E5=8A=A0=E6=99=82?= =?UTF-8?q?=E3=81=AE=E3=82=A8=E3=83=A9=E3=83=BC=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/StockPage.tsx | 41 +++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/frontend/src/pages/StockPage.tsx b/frontend/src/pages/StockPage.tsx index 109948e..db2fbd1 100644 --- a/frontend/src/pages/StockPage.tsx +++ b/frontend/src/pages/StockPage.tsx @@ -123,8 +123,21 @@ const StockPage: React.FC = () => { if (newStock.newAddition) { newStock.stuffId = null; } - if (isNaN(newStock.amount)) return; - if (newStock.price === null || isNaN(newStock.price)) return; + + if (!newStock.stuffId && !newStock.stuffName) { + showErrorMessage(GENERAL_ERRORS.INVALID_STUFF_NAME); + return; + } + + if (isNaN(newStock.amount)) { + showErrorMessage(GENERAL_ERRORS.INVALID_AMOUNT); + return; + } + + if (newStock.price === null || isNaN(newStock.price)) { + showErrorMessage(GENERAL_ERRORS.INVALID_PRICE); + return; + } if (newStock.buyAmount !== null && isNaN(newStock.buyAmount)) { newStock.buyAmount = null; @@ -684,11 +697,11 @@ const StockPage: React.FC = () => { label="購入店舗" fullWidth value={newStock.shop} - onChange={(e) => setNewStock({...newStock, shop: e.target.value})} + onChange={(e) => setNewStock({ ...newStock, shop: e.target.value })} /> {/* 購入日・消費期限を横並びに */} - + {/* 購入日・賞味期限入力 */} setNewStock({ ...newStock, buyDate, expDate })} /> @@ -706,15 +719,15 @@ const StockPage: React.FC = () => { {/* 各カテゴリを表示 */} {CATEGORY_NAMES.map(category => { return ( - - setOpenCategory({...openCategory, [category]: !openCategory[category]})} - > - {!openCategory[category] ? : } - {category} - - {openCategory[category] && StockTable(stocks, [category])} - + + setOpenCategory({ ...openCategory, [category]: !openCategory[category] })} + > + {!openCategory[category] ? : } + {category} + + {openCategory[category] && StockTable(stocks, [category])} + ) })} @@ -727,7 +740,7 @@ const StockPage: React.FC = () => { 材料の追加 */} - + ); };