import { useEffect, useRef, useState } from "react"; import useFocus from "../../hooks/useFocus.hook.jsx"; import { csvGen } from "../../requests/requests.exos.js"; import styles from "../../styles/exos/ExoPrinterForm.module.scss"; import { parseClassName } from "../../utils/utils.js"; import StepExemple from "./StepExemple.jsx"; import StepOptions from "./StepOptions.jsx"; export default function ExoPrinterForm({ step }) { const [options, setOptions] = useState({ pages: 5, serie: 10, name: "", }); const pageChange = (num) => { setOptions({ ...options, pages: num, }); }; const serieChange = (num) => { setOptions({ ...options, serie: num, }); }; const ref = useRef(); useEffect(() => { if (ref.current != null) ref.current.focus(); }, []); return ( <>
{" "} { setOptions({ ...options, name: e.target.value }); }} tabIndex="-1" ref={ref} onKeyUp={(e) => { if (e.code == "Enter") { csvGen( step.id_code, options.name !== "" ? options.name : "untitled" ); } }} disabled={!step.isCsv} />
{step.exemple.data && (

Exemples ({step.exemple.type && step.exemple.type})

)}

{step.consigne}

{step.exemple.data && step.exemple.data.slice(0, 3).map((ex, i) => { return (

{ex.calcul}

); })} {step.exemple.data &&

...

} {!step.exemple.data &&

Exemples indisponibles

}
); }