From 7ef4af88d50c3552999fa5a42507d2a08eecffd2 Mon Sep 17 00:00:00 2001 From: Yasmim Rosa Date: Wed, 13 Dec 2023 17:12:51 -0300 Subject: [PATCH] =?UTF-8?q?matr=C3=ADcula=20em=20eletivas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/CreateTrilhas/index.js | 4 +++- .../src/pages/NewEnrolmentElectives/index.js | 16 +++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/frontend/src/pages/CreateTrilhas/index.js b/frontend/src/pages/CreateTrilhas/index.js index 8434198a..77768d36 100644 --- a/frontend/src/pages/CreateTrilhas/index.js +++ b/frontend/src/pages/CreateTrilhas/index.js @@ -55,10 +55,11 @@ const CreateTrilhas = () => { serie: yup.string().required("A série é obrigatória"), eletivas: yup .array() - .min(1, "É necessário selecionar pelo menos uma eletiva") + .min(1, "É necessário selecionar pelo menos uma eletiva além do Projeto de Vida") .required("É necessário selecionar eletivas relacionadas"), }), onSubmit: async (values) => { + values.eletivas.push("Projeto de Vida") try { const response = await axios.post( "http://localhost:3001/learningpath/createLearningPaths", @@ -220,6 +221,7 @@ const CreateTrilhas = () => { } > + Projeto de Vida {isLoading ? ( {formik.errors.eletivas} diff --git a/frontend/src/pages/NewEnrolmentElectives/index.js b/frontend/src/pages/NewEnrolmentElectives/index.js index 39e50e7e..7dda12d2 100644 --- a/frontend/src/pages/NewEnrolmentElectives/index.js +++ b/frontend/src/pages/NewEnrolmentElectives/index.js @@ -15,7 +15,7 @@ import ButtonCadastrar from "../../components/Button"; import { Link } from "react-router-dom"; -const NewEnrolmentLP = () => { +const NewEnrolmentElectives = () => { const { userId, userSy } = useAuth(); const user = userId() const schoolYear = userSy() @@ -50,6 +50,9 @@ const NewEnrolmentLP = () => { fetchEletivas(); }, []); + const eletivasFiltradas = eletivas.filter((eletiva) => eletiva.school_year === parseInt(schoolYear)); + + const formik = useFormik({ initialValues: { eletivas: [], @@ -59,15 +62,17 @@ const NewEnrolmentLP = () => { let requiredCount; if (parseInt(schoolYear) === 1) { - requiredCount = 6; + requiredCount = 5; } else if (parseInt(schoolYear) === 2 || parseInt(schoolYear) === 3) { - requiredCount = 4; + requiredCount = 3; } return value.length === requiredCount; }), }), onSubmit: async(values) => { + values.eletivas.push("Projeto de Vida") + try{ const response = await axios.post("http://localhost:3001/elective/matricula-eletivas", { @@ -144,7 +149,8 @@ const NewEnrolmentLP = () => { formik.setFieldValue("eletivas", values) }> - {eletivas.map((eletiva) => + Projeto de Vida + {eletivasFiltradas.map((eletiva) => {eletiva.name} )} @@ -170,4 +176,4 @@ const NewEnrolmentLP = () => { ); }; -export default NewEnrolmentLP; +export default NewEnrolmentElectives;