import dynamic from "next/dynamic"; import { useEffect, useState } from "react"; import { CODE_SEPARATOR, PYTHON_DEFAULT } from "../../utils/constant.js"; import styles from "../../styles/exos/ModelInput.module.scss"; import { parseClassName } from "../../utils/utils.js"; import { MdOutlineOpenInNew } from "react-icons/md"; import { RiErrorWarningFill } from "react-icons/ri"; import { FiUpload } from "react-icons/fi"; import { FaDownload } from "react-icons/fa"; import { getExoModelFile } from "../../requests/requests.exos.js"; let CustomEditor; if (typeof window !== "undefined") { CustomEditor = dynamic(() => import("./Editor.jsx")); } export default function ModelInput({ model, onChange, setModel, setFull, full, step, tempSpec, }) { const [python, setPython] = useState(""); useEffect(() => { if (full) { setPython(model.data ? model.data : PYTHON_DEFAULT); } return () => { setPython(""); }; }, [full]); return ( <> {!full && (
{/* {python !== model.model && } */}

ou

{ let text = await e.target.files[0].text().then((res) => res); var filename = e.target.files[0].name; var splitting = filename.split("."); if (splitting[splitting.length - 1] != "py") { } else { setModel({ filename: e.target.files[0].name, data: text }); } }} className={styles["inputfile"]} />
{model.filename == "" || !model.filename ? "..." : model.filename} {model.download && { getExoModelFile(step.id_code) }}/>}
)} {full && ( <> {CustomEditor && full && ( { setPython(e); }} setOptions={{ showLineNumbers: true, tabSize: 2, }} //editorProps={{ $blockScrolling: true }} enableBasicAutocompletion={false} enableLiveAutocompletion={true} //enableSnippets={true} className="model_input-code_input" showPrintMargin={false} validate={(e) => { e.preventDefault(); onChange && onChange({ data: python, filename: model.filename }); setFull(false); }} cancel={() => { setFull(false); setPython(tempSpec.exo_model.data); }} filename={model.filename} /> )} )} ); }