From 54b9539c0f3de3cf13500d56e5c0b20b204ced70 Mon Sep 17 00:00:00 2001 From: "Masaharu.Kato" Date: Mon, 16 Jun 2025 11:17:58 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AC=E3=82=B7=E3=83=94=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E6=99=82=E3=81=AE=E3=82=A8=E3=83=A9=E3=83=BC=E3=83=A1=E3=83=83?= =?UTF-8?q?=E3=82=BB=E3=83=BC=E3=82=B8=E3=82=92=E8=A1=A8=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/AddRecipe.tsx | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/frontend/src/pages/AddRecipe.tsx b/frontend/src/pages/AddRecipe.tsx index e96a779..72ca041 100644 --- a/frontend/src/pages/AddRecipe.tsx +++ b/frontend/src/pages/AddRecipe.tsx @@ -84,23 +84,28 @@ const AddRecipe: React.FC = () => { return false; } - if (!recipeId) { - // 新規追加 - const response = await recipeApi.addRecipe({ + try { + if (!recipeId) { + // 新規追加 + const response = await recipeApi.addRecipe({ + recipeName, + summary: recipeSummary, + stuffAndAmountArray: items, + }) + return response.recipeId; + } + + const response = await recipeApi.updateRecipe({ + recipeId, recipeName, summary: recipeSummary, stuffAndAmountArray: items, }) - return response.recipeId; + } catch { + alert('レシピの送信に失敗しました。既に同じ名前の料理が存在する可能性があります。'); + return false; } - const response = await recipeApi.updateRecipe({ - recipeId, - recipeName, - summary: recipeSummary, - stuffAndAmountArray: items, - }) - return recipeId; }