hiesoftrd 1 жил өмнө
parent
commit
13fe8e08c9

BIN
frontend/src/assets/chat_notify.mp3


BIN
frontend/src/assets/dialogflow.png


BIN
frontend/src/assets/logo.png


BIN
frontend/src/assets/n8n.png


BIN
frontend/src/assets/planilha.xlsx


BIN
frontend/src/assets/sound.mp3


BIN
frontend/src/assets/sound.ogg


BIN
frontend/src/assets/typebot.jpg


BIN
frontend/src/assets/wa-background-dark.png


BIN
frontend/src/assets/wa-background.png


BIN
frontend/src/assets/webhook.png


+ 56 - 0
frontend/src/errors/toastError.js

@@ -0,0 +1,56 @@
+import { toast } from "react-toastify";
+import { i18n } from "../translate/i18n";
+import { isString } from 'lodash';
+
+const toastError = err => {
+    const errorMsg = err.response?.data?.error;
+    if (errorMsg) {
+        if (i18n.exists(`backendErrors.${errorMsg}`)) {
+            console.error(`Error: ${i18n.t(`backendErrors.${errorMsg}`)}`);
+            // Optionally log the error to an external service here
+            
+            toast.error(i18n.t(`backendErrors.${errorMsg}`), {
+                toastId: errorMsg,
+                autoClose: 2000,
+                hideProgressBar: false,
+                closeOnClick: true,
+                pauseOnHover: false,
+                draggable: true,
+                progress: undefined,
+                theme: "light",
+            });
+            
+            return;
+        } else {
+            
+            toast.error(errorMsg, {
+                toastId: errorMsg,
+                autoClose: 2000,
+                hideProgressBar: false,
+                closeOnClick: true,
+                pauseOnHover: false,
+                draggable: true,
+                progress: undefined,
+                theme: "light",
+            });
+            
+            return;
+        }
+    } if (isString(err)) {
+        console.error(`Error: ${err}`);
+        // Optionally log the error to an external service here
+        /*
+        toast.error(err);
+        */
+        return;
+    } else {
+        console.error("An error occurred!");
+        // Optionally log the error to an external service here
+        /*
+        toast.error("An error occurred!");
+        */
+        return;
+    }
+};
+
+export default toastError;