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); // ダイアログを閉じる