import { useRouter } from "next/router"; import { useEffect, useState } from "react"; import { getExos, getTags } from "../../requests/requests.exos.js"; import { editParcours, getEditParcoursInfos, getParcoursInfos, } from "../../requests/requests.room.js"; import { isBrowser } from "../../utils/utils.js"; import Layout from "../Layout.js"; import SelectExo from "../pdf_gen/selectExo.jsx"; import styles from "../../styles/room/parcoursEdit.module.scss"; import Input from "../Input.jsx"; import { AlertType, useAlert } from "../../context/alert.context.js"; import { notificationService } from "../../services/notification.service.js"; import Back from "./back.jsx"; export default function ParcoursEdit({ parcours_id, room_code, user }) { const [parcours, setParcours] = useState(); const router = useRouter(); const [options, setOptions] = useState({ name: "", timer: 0, success_condition: 0, }); const [empty, setEmpty] = useState(false); const [exosList, setExos] = useState([]); const alert = useAlert(); useEffect(() => { if (!user.owner) { router.push("/room/" + roomCode, undefined, { shallow: true, }); } }, []); useEffect(() => { if (!parcours) { getEditParcoursInfos(parcours_id) .then((res) => { setExos([ ...res.exercices.map((ex) => { return { id_code: ex.id_code, numberInExo: ex.number, name: ex.name, }; }), ]); setOptions({ name: res.name, timer: res.timer, success_condition: res.success_condition, }); }) .catch((err) => { router.push({ pathname: "/room/" + room_code }); }); } }, []); return (

Modification de parcours

{ setOptions({ ...options, name: e.target.value }); }} /> { setOptions({ ...options, timer: parseInt(e.target.value) }); }} /> { setOptions({ ...options, success_condition: parseInt(e.target.value), }); }} />
); }