From da1324f200dc8e0725b63916c329c2696e52e743 Mon Sep 17 00:00:00 2001 From: vjspranav Date: Fri, 16 Feb 2024 18:55:57 +0530 Subject: [PATCH] Deploy explain API --- src/Constants.js | 3 ++- src/components/MonacoEditor.js | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Constants.js b/src/Constants.js index 38432fc..86758a1 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -1,4 +1,5 @@ const API_URL = "https://api.stagb.in/dev/content/"; +const EXPLAIN_URL = "https://api.stagb.in/dev/explain/"; const RAW_URL = "https://raw.stagb.in/StagBIN-Raw/"; -export { API_URL, RAW_URL }; +export { API_URL, RAW_URL, EXPLAIN_URL }; diff --git a/src/components/MonacoEditor.js b/src/components/MonacoEditor.js index 3ceeee4..a0dac49 100644 --- a/src/components/MonacoEditor.js +++ b/src/components/MonacoEditor.js @@ -16,7 +16,7 @@ import Backdrop from "@material-ui/core/Backdrop"; import CircularProgress from "@material-ui/core/CircularProgress"; import { Box, makeStyles } from "@material-ui/core"; -import { API_URL } from "../Constants"; +import { API_URL, EXPLAIN_URL } from "../Constants"; import { StagBinContext } from "../App"; import detectLanguage from "../utils/language"; @@ -111,13 +111,20 @@ export default function MEditor() { const handleOpen = () => { setOpen(true); - setInterval(() => { - setExplanation("We are still learning..."); - }, 3000); + axios + .post(EXPLAIN_URL, { data: data }) + .then((res) => { + setExplanation(res.data.body); + }) + .catch((err) => { + console.log(err); + setExplanation("Failed to understand the content"); + }); }; const handleClose = () => { setOpen(false); + setExplanation(""); }; useEffect(() => {