From e4f5df9bad18ec6865b2861e27ae481553bf7f6c Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Sun, 16 Jul 2023 17:10:09 -0300 Subject: [PATCH] Removed unused file --- src/frontend/src/modals/codeAreaModal/v2.tsx | 191 ------------------- 1 file changed, 191 deletions(-) delete mode 100644 src/frontend/src/modals/codeAreaModal/v2.tsx diff --git a/src/frontend/src/modals/codeAreaModal/v2.tsx b/src/frontend/src/modals/codeAreaModal/v2.tsx deleted file mode 100644 index a677fe444..000000000 --- a/src/frontend/src/modals/codeAreaModal/v2.tsx +++ /dev/null @@ -1,191 +0,0 @@ -// organize-imports-ignore -import { useContext, useEffect, useRef, useState } from "react"; -import { PopUpContext } from "../../contexts/popUpContext"; -import "ace-builds/src-noconflict/ace"; -import { darkContext } from "../../contexts/darkContext"; -import { postCustomComponent, postValidateCode } from "../../controllers/API"; -import { alertContext } from "../../contexts/alertContext"; -import { Button } from "../../components/ui/button"; -import { CODE_PROMPT_DIALOG_SUBTITLE } from "../../constants"; -import { APIClassType } from "../../types/api"; -import { DialogTitle } from "@radix-ui/react-dialog"; -import { TerminalSquare } from "lucide-react"; -import AceEditor from "react-ace"; -import "ace-builds/src-noconflict/mode-python"; -import "ace-builds/src-noconflict/theme-github"; -import "ace-builds/src-noconflict/theme-twilight"; -import "ace-builds/src-noconflict/ext-language_tools"; -import "ace-builds/src-noconflict/ace"; -import BaseModal from "../baseModal"; - -export default function CodeAreaModal({ - value, - setValue, - nodeClass, - setNodeClass, - dynamic, -}: { - setValue: (value: string) => void; - value: string; - nodeClass: APIClassType; - setNodeClass: (Class: APIClassType) => void; - dynamic?: boolean; -}) { - const [open, setOpen] = useState(true); - const [code, setCode] = useState(value); - const [loading, setLoading] = useState(false); - const { dark } = useContext(darkContext); - const { setErrorData, setSuccessData } = useContext(alertContext); - const [height, setHeight] = useState(null); - const [error, setError] = useState<{ - detail: { error: string; traceback: string }; - }>(null); - const { closePopUp, setCloseEdit } = useContext(PopUpContext); - function setModalOpen(x: boolean) { - setOpen(x); - if (x === false) { - setTimeout(() => { - setCloseEdit("editcode"); - closePopUp(); - }, 300); - } - } - useEffect(() => { - setValue(code); - }, [code, setValue]); - - useEffect(() => { - handleClick(); - }, []) - - function handleClick() { - setLoading(true); - if (!dynamic) { - postValidateCode(code) - .then((apiReturn) => { - setLoading(false); - if (apiReturn.data) { - let importsErrors = apiReturn.data.imports.errors; - let funcErrors = apiReturn.data.function.errors; - if (funcErrors.length === 0 && importsErrors.length === 0) { - setSuccessData({ - title: "Code is ready to run", - }); - // setValue(code); - } else { - if (funcErrors.length !== 0) { - setErrorData({ - title: "There is an error in your function", - list: funcErrors, - }); - } - if (importsErrors.length !== 0) { - setErrorData({ - title: "There is an error in your imports", - list: importsErrors, - }); - } - } - } else { - setErrorData({ - title: "Something went wrong, please try again", - }); - } - }) - .catch((_) => { - setLoading(false); - setErrorData({ - title: "There is something wrong with this code, please review it", - }); - }); - } else { - postCustomComponent(code, nodeClass) - .then((apiReturn) => { - const { data } = apiReturn; - if (data) { - setNodeClass(data); - setModalOpen(false); - } - }) - .catch((err) => { - setError(err.response.data); - }); - } - } - - /// use effect to update ace editor on error to handle right scroll - useEffect(() => { - // Function to be executed after the state changes - const delayedFunction = setTimeout(() => { - if (error?.detail.error !== undefined) { - //trigger to update the height, does not really apply any height - setHeight("90%"); - } - //600 to happen after the transition of 500ms - }, 600); - - // Cleanup function to clear the timeout if the component unmounts or the state changes again - return () => { - clearTimeout(delayedFunction); - }; - }, [error, setHeight]); - - return ( - - - - Edit Code - - - -
-
- { - setCode(value); - }} - className="h-full w-full rounded-lg border-[1px] border-gray-300 custom-scroll dark:border-gray-600" - /> -
-
-
-

- {error?.detail?.error} -

-
-
-                  {error?.detail?.traceback}
-                
-
-
-
-
- -
-
-
-
- ); -}