From db84aaaf0a2bf532fc352b8494637eb7af14ba92 Mon Sep 17 00:00:00 2001 From: Tony Salomone <dadmobile@gmail.com> Date: Sat, 30 Nov 2024 16:39:16 -0500 Subject: [PATCH] Display error message if recipe upload responds with one. --- .../components/Experiment/Train/ImportRecipeModal.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/Experiment/Train/ImportRecipeModal.tsx b/src/renderer/components/Experiment/Train/ImportRecipeModal.tsx index 00c22f7b..5a4c9c8d 100644 --- a/src/renderer/components/Experiment/Train/ImportRecipeModal.tsx +++ b/src/renderer/components/Experiment/Train/ImportRecipeModal.tsx @@ -63,11 +63,11 @@ export default function ImportRecipeModal({ open, setOpen, mutate }) { // For now: Remove the last . and extension from the filename const recipe_name = file.name.replace(/\.[^/.]+$/, ''); - uploadRecipe(recipe_name, recipe_text); + return uploadRecipe(recipe_name, recipe_text); }; // Given a recipe string, uploads to API. - const uploadRecipe = async (recipe_name, recipe_text) => { + const uploadRecipe = async (recipe_name: string, recipe_text: string) => { setUploading(true); //This is for the loading spinner const response = await fetch( chatAPI.Endpoints.Recipes.Import(recipe_name), @@ -86,6 +86,9 @@ export default function ImportRecipeModal({ open, setOpen, mutate }) { }) .then((data) => { console.log('Server response:', data); + if (data?.status == "error") { + alert(data.message); + } }) .catch((error) => { alert(error); -- GitLab