From 1d38dd1c4d76af52f5db95bdef3c4723e7e1d5e6 Mon Sep 17 00:00:00 2001 From: Eli Pedro Date: Sun, 29 Oct 2023 22:53:10 -0300 Subject: [PATCH] =?UTF-8?q?Inicio=20da=20integra=C3=A7=C3=A3o=20de=20profe?= =?UTF-8?q?ssor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/containers/Perfis/Professor.js | 114 +++++++++++------- 1 file changed, 71 insertions(+), 43 deletions(-) diff --git a/biblioconex/src/containers/Perfis/Professor.js b/biblioconex/src/containers/Perfis/Professor.js index ad5340f..91ab088 100644 --- a/biblioconex/src/containers/Perfis/Professor.js +++ b/biblioconex/src/containers/Perfis/Professor.js @@ -1,50 +1,78 @@ -import React, { useState } from 'react'; -import { Link } from 'react-router-dom'; +import React, {useEffect, useState} from 'react'; +import {Link} from 'react-router-dom'; import './professor.css'; +import axios from "axios"; + +const instance = axios.create({ + baseURL: process.env.REACT_APP_ENV +}) function Professor() { - // Suponha que você tenha a lista de turmas do professor - const turmasDoProfessor = ['Turma A', 'Turma B', 'Turma C']; - - const [turmaSelecionada, setTurmaSelecionada] = useState(''); - - const handleTurmaChange = (event) => { - setTurmaSelecionada(event.target.value); - }; - - return ( -
-

MEU PERFIL

-

Nome completo do professor

- -

- - CLIQUE PARA TER ACESSO A TODAS AS SUAS TURMAS - -

- -
-

REGISTRAR TEXTO

-
- - - {/* Dropdown de seleção para turmas do professor */} - - - - -
Salvar
+ + const [turmasProfessor, setTurmasProfessor] = useState([]); + const [turmaSelecionada, setTurmaSelecionada] = useState(''); + const [nomeProfessor, setNomeProfessor] = useState('Professor Fulano da Silva'); + + const handleTurmaChange = (event) => { + setTurmaSelecionada(event.target.value); + }; + + useEffect(() => { + getNomeProfessor(setNomeProfessor); + getTurmasProfessor(setTurmasProfessor); + }, []); + + + return ( +
+

MEU PERFIL

+

{nomeProfessor}

+ +

+ + CLIQUE PARA TER ACESSO A TODAS AS SUAS TURMAS + +

+ +
+

REGISTRAR TEXTO

+
+ + + {/* Dropdown de seleção para turmas do professor */} + + + + +
Salvar
+
+
-
-
- ); + ); +} + +function getNomeProfessor(setNomeProfessor) { + instance.get('/api/professores/' + localStorage.getItem("idUsuario")).then((response) => { + setNomeProfessor(response.data.nome); + }).catch((error) => { + console.log('ERROR: GET PROFESSOR: ', error); + }); } +function getTurmasProfessor(setTurmasProfessor) { + instance.get('/api/professores/' + localStorage.getItem("idUsuario") + '/turma').then((response) => { + setTurmasProfessor(response.data); + }).catch((error) => { + console.log('ERROR: GET TURMAS PROFESSOR: ', error); + }); +} + + export default Professor;