diff --git a/backend/account/serializers.py b/backend/account/serializers.py index f5d11cc9..b9c0e06a 100644 --- a/backend/account/serializers.py +++ b/backend/account/serializers.py @@ -1,5 +1,5 @@ from rest_framework import serializers -from account.models import User +from account.models import User, MateriaSelecionada from django.utils.encoding import smart_str, force_bytes, DjangoUnicodeDecodeError from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encode from django.contrib.auth.tokens import PasswordResetTokenGenerator @@ -114,4 +114,12 @@ def validate(self, attrs): # Serializador para 'MateriaSelecionada' class SelecionarMateriaSerializer(serializers.Serializer): - idTurmaProfessor = serializers.IntegerField() \ No newline at end of file + idTurmaProfessor = serializers.IntegerField() + + +# Serializador para 'MateriaSelecionada' + +class MandarMateriaSerializer(serializers.ModelSerializer): + class Meta: + model = MateriaSelecionada + fields = '__all__' \ No newline at end of file diff --git a/backend/account/urls.py b/backend/account/urls.py index 2eaba8c5..a3d8c142 100644 --- a/backend/account/urls.py +++ b/backend/account/urls.py @@ -8,6 +8,7 @@ UserPasswordResetView, processar_horario, selecionar_materia, + mandar_materiaView, ) # Definição de padrões de URL para as visualizações correspondentes @@ -20,4 +21,6 @@ path('reset-password///', UserPasswordResetView.as_view(), name='reset-password'), # Rota para redefinição de senha path('horario/', processar_horario, name='processar_horario'), # Rota para processamento de horário path('selecionar_materia/', selecionar_materia, name='selecionar_materia'), # Rota para seleção de matéria + path('mandar_materias/', mandar_materiaView.as_view(), name='mandar_materia'), + ] \ No newline at end of file diff --git a/backend/account/views.py b/backend/account/views.py index eb4a77c0..3de20f75 100644 --- a/backend/account/views.py +++ b/backend/account/views.py @@ -9,6 +9,7 @@ UserProfileSerializer, UserRegistrationSerializer, SelecionarMateriaSerializer, + MandarMateriaSerializer, ) from django.contrib.auth import authenticate from account.renderers import UserRenderer @@ -143,4 +144,13 @@ def obter_dados_do_json(id_turma_professor): # Filtra as chaves que correspondem aos campos do modelo dados_filtrados = {campo.name: turma[campo.name] for campo in MateriaSelecionada._meta.get_fields() if campo.name in turma} return dados_filtrados - return None \ No newline at end of file + return None + + +#manda a materia de volta para o frontend +class mandar_materiaView(APIView): + def get(self, request): + dados = MateriaSelecionada.objects.all() + serializer = MandarMateriaSerializer(dados, many=True) + + return Response(serializer.data) \ No newline at end of file diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 569f2d6a..1b5ba906 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -16,6 +16,7 @@ "@testing-library/jest-dom": "^5.16.1", "@testing-library/react": "^12.1.2", "@testing-library/user-event": "^13.5.0", + "axios": "^1.6.2", "papaparse": "^5.4.1", "react": "^17.0.2", "react-dom": "^17.0.2", @@ -4769,6 +4770,29 @@ "node": ">=4" } }, + "node_modules/axios": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/axobject-query": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", @@ -7799,9 +7823,9 @@ "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==" }, "node_modules/follow-redirects": { - "version": "1.14.7", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", - "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==", + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", + "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", "funding": [ { "type": "individual", @@ -13203,6 +13227,11 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/psl": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", @@ -19746,6 +19775,28 @@ "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.3.5.tgz", "integrity": "sha512-WKTW1+xAzhMS5dJsxWkliixlO/PqC4VhmO9T4juNYcaTg9jzWiJsou6m5pxWYGfigWbwzJWeFY6z47a+4neRXA==" }, + "axios": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", + "requires": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + }, + "dependencies": { + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, "axobject-query": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", @@ -22003,9 +22054,9 @@ "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==" }, "follow-redirects": { - "version": "1.14.7", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", - "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==" + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", + "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==" }, "fork-ts-checker-webpack-plugin": { "version": "6.5.0", @@ -25772,6 +25823,11 @@ } } }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "psl": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index 879e952c..8af7d173 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -11,6 +11,7 @@ "@testing-library/jest-dom": "^5.16.1", "@testing-library/react": "^12.1.2", "@testing-library/user-event": "^13.5.0", + "axios": "^1.6.2", "papaparse": "^5.4.1", "react": "^17.0.2", "react-dom": "^17.0.2", diff --git a/frontend/src/pages/Grade.js b/frontend/src/pages/Grade.js index 854c17a6..a95896de 100644 --- a/frontend/src/pages/Grade.js +++ b/frontend/src/pages/Grade.js @@ -1,7 +1,8 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import Grade from '../styleheets/Grade.css'; // Importe o arquivo de estilo corretamente import { Grid } from "@mui/material"; import Navbar from "../components/Navbar"; +import axios from 'axios'; const Critérios = () => { @@ -13,6 +14,19 @@ const Critérios = () => { ['', '', '', '', ''], ]); + const [valoresBack, setValoresBack] = useState([]); + //pegar os dados do back + useEffect(() => { + axios.get('http://127.0.0.1:8000/api/user/mandar_materias') + .then(response => { + console.log(response.data); + setValoresBack(response.data); + }) + .catch(error => { + console.error('Erro ao buscar dados:', error); + }); + }, []); + const handleInputChange = (row, col, value) => { const newInputValues = [...inputValues]; newInputValues[row][col] = value; @@ -54,13 +68,26 @@ const Critérios = () => { ); }; + + return (

Adicione os critérios:

{renderTable()} + {valoresBack.length > 0 && ( +
+

Horários das matérias:

+
    + {valoresBack.map((materia, index) => ( +
  • {materia.horario}
  • + ))} +
+
+ )}
+ ); };