2022-05-18 10:15:54 +02:00
|
|
|
import styles from "../../styles/pdf_gen/paramItem.module.scss";
|
|
|
|
import { ImCross } from "react-icons/im";
|
2022-06-24 13:42:16 +02:00
|
|
|
export default function ParamItem({
|
|
|
|
exo,
|
|
|
|
unSelect,
|
|
|
|
setExo,
|
|
|
|
onlyNumber = false,
|
|
|
|
}) {
|
2022-05-18 10:15:54 +02:00
|
|
|
return (
|
|
|
|
<div className={styles["item"]}>
|
|
|
|
<div className={styles["name-container"]}>
|
2022-06-24 13:42:16 +02:00
|
|
|
<ImCross onClick={unSelect}/>
|
2022-05-18 10:15:54 +02:00
|
|
|
<p>{exo.name}</p>
|
|
|
|
</div>
|
|
|
|
<div className={styles["param-container"]}>
|
2022-06-24 13:42:16 +02:00
|
|
|
{!onlyNumber && (
|
|
|
|
<>
|
|
|
|
<label>Nombre d'exercice</label>
|
|
|
|
<input
|
|
|
|
type="number"
|
|
|
|
step={1}
|
|
|
|
min={1}
|
|
|
|
max={10}
|
|
|
|
value={exo.numberOfExo}
|
|
|
|
onChange={(e) => {
|
|
|
|
if (
|
|
|
|
(parseInt(e.target.value) <= 10 &&
|
|
|
|
parseInt(e.target.value) >= 1) ||
|
|
|
|
e.target.value == ""
|
|
|
|
) {
|
|
|
|
setExo(exo.numberInExo, parseInt(e.target.value));
|
|
|
|
} else if (isNaN(parseInt(e.target.value))) {
|
|
|
|
setExo(exo.numberInExo, exo.numberOfExo);
|
|
|
|
} else if (parseInt(e.target.value) > 10) {
|
|
|
|
setExo(exo.numberInExo, 10);
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)}
|
2022-05-18 10:15:54 +02:00
|
|
|
<label>Nombre dans l'exercice</label>
|
|
|
|
<input
|
|
|
|
type="number"
|
|
|
|
step={1}
|
|
|
|
min={5}
|
|
|
|
max={30}
|
|
|
|
value={exo.numberInExo}
|
|
|
|
onChange={(e) => {
|
2022-06-24 13:42:16 +02:00
|
|
|
if (
|
|
|
|
(parseInt(e.target.value) <= 30 &&
|
|
|
|
parseInt(e.target.value) >= 1) ||
|
|
|
|
e.target.value == ""
|
|
|
|
) {
|
2022-05-18 10:15:54 +02:00
|
|
|
setExo(parseInt(e.target.value), exo.numberOfExo);
|
2022-06-24 13:42:16 +02:00
|
|
|
} else if (parseInt(e.target.value) > 30) {
|
|
|
|
setExo(30, exo.numberOfExo);
|
2022-05-18 10:15:54 +02:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|