From fe204dc4d72958a2b832007e2cc36f78b804093d Mon Sep 17 00:00:00 2001 From: "Masaharu.Kato" Date: Wed, 18 Jun 2025 14:06:41 +0900 Subject: [PATCH] =?UTF-8?q?=E8=B2=B7=E3=81=86=E3=82=82=E3=81=AE=E3=83=AA?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=81=A7=E6=9D=90=E6=96=99=E5=90=8D=E3=81=8C?= =?UTF-8?q?=E7=A9=BA=E7=99=BD=E3=81=AE=E6=99=82=E8=BF=BD=E5=8A=A0=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/constants/errorMessages.ts | 1 + frontend/src/pages/TaskListPage.tsx | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/frontend/src/constants/errorMessages.ts b/frontend/src/constants/errorMessages.ts index 7dab57b..d3a3f78 100644 --- a/frontend/src/constants/errorMessages.ts +++ b/frontend/src/constants/errorMessages.ts @@ -6,6 +6,7 @@ // 一般的なエラーメッセージ export const GENERAL_ERRORS = { UNEXPECTED_ERROR: '予期せぬエラーが発生しました', + INVALID_STUFF_NAME: '材料名が正しく入力されていません。', INVALID_AMOUNT: '数量が正しく入力されていません。', INVALID_PRICE: '価格が正しく入力されていません。', }; diff --git a/frontend/src/pages/TaskListPage.tsx b/frontend/src/pages/TaskListPage.tsx index 51a7f06..9aacd45 100644 --- a/frontend/src/pages/TaskListPage.tsx +++ b/frontend/src/pages/TaskListPage.tsx @@ -158,6 +158,13 @@ const TaskListPage: React.FC = () => { return; } + newToBuy.stuffName = newToBuy.stuffName.trim(); // 材料名の前後の空白を削除 + + if (!newToBuy.stuffName) { + showErrorMessage(GENERAL_ERRORS.INVALID_STUFF_NAME); + return; + } + console.log(newToBuy) await toBuyApi.addToBuy(newToBuy); setOpenAddToBuyDialog(false); // ダイアログを閉じる