Skip to content

Commit

Permalink
Adicionando opção de assunto e adicionando listagem de questões.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigoborgesmachado committed Feb 20, 2024
1 parent b043cbd commit f6f923e
Show file tree
Hide file tree
Showing 18 changed files with 626 additions and 123 deletions.
17 changes: 10 additions & 7 deletions src/components/Navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {Link} from 'react-router-dom';
import { toast } from 'react-toastify';
import api from '../../services/api.js';

const pages = ['📚 Provas', '🧾 Simulados', '📒Avaliações', '🎓 Sisu', '➕Pratique Tabuada'];
const pages = ['📚 Provas', '🧾 Simulados', '📒Avaliações', '📔Questões', '🎓 Sisu', '➕Pratique Tabuada'];
if(localStorage.getItem(Config.ADMIN) === '1'){
pages.push('Admin');
}
Expand Down Expand Up @@ -120,7 +120,10 @@ const ResponsiveAppBar = () => {
else if(page === pages[2]){
navigate('/avaliacoes', {replace: true});
}
else if(page === pages[4]){
else if(page === pages[3]){
navigate('/listagemquestoes', {replace: true});
}
else if(page === pages[5]){
window.open("https://www.tabuadadivertida.com/", "_blank");
}
}
Expand Down Expand Up @@ -198,7 +201,7 @@ const ResponsiveAppBar = () => {
function abreTelaQuestoes(){
handleCloseAdminMenu();
handleCloseNavMenu();
navigate('/listagemquestoes/-1', {replace: true});
navigate('/listagemquestoes', {replace: true});
}

function abreTelaLogs(){
Expand Down Expand Up @@ -284,7 +287,7 @@ const ResponsiveAppBar = () => {
}}
>
{pages.map((page, index) => (
index != 0 && index != 3 && index != 5 ?
index != 0 && index != 4 && index != 6 ?
<MenuItem key={index} onClick={(e) => SelecionaOpcao(page)}>
<Typography textAlign="center">
{page}
Expand Down Expand Up @@ -327,7 +330,7 @@ const ResponsiveAppBar = () => {
</Menu>
</>
:
index == 3?
index == 4?
<>
<MenuItem key={page} onClick={handleOpenSisuMenu} >
<Typography textAlign="center">
Expand Down Expand Up @@ -425,7 +428,7 @@ const ResponsiveAppBar = () => {
</Typography>
<Box sx={{ flexGrow: 1, display: { xs: 'none', md: 'flex' } }}>
{pages.map((page, index) => (
index != 0 && index != 3 && index != 5 ?
index != 0 && index != 4 && index != 6 ?
<Button
key={index}
onClick={(e) => SelecionaOpcao(page)}
Expand Down Expand Up @@ -467,7 +470,7 @@ const ResponsiveAppBar = () => {
</Menu>
</>
:
index == 3 ?
index == 4 ?
<>
<Button key={index} onClick={handleOpenSisuMenu} sx={{ my: 2, color: 'white', display: 'block' }}>
{page}
Expand Down
3 changes: 2 additions & 1 deletion src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"TEMPO_PARAM":"tempo",
"Historico": "historico",
"PaginaListagem": "PAGINALISTAGEM",
"FiltroProva": "FILTROPROVA"
"FiltroProva": "FILTROPROVA",
"lastLink": "LASTLINK"
}
18 changes: 18 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -781,4 +781,22 @@ table{

.select-item{
color: black;
}

.detalhes-modal-separado{
display: flex;
flex-direction: column;
}

.detalhes-modal-separado h4{
margin: 8px;
}

.opcoes-top-tabela{
display: flex;
justify-content: space-between;
}

.link{
cursor: pointer;
}
1 change: 1 addition & 0 deletions src/pages/Admin/HistoricoUsuario/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ function HistoricoUsuarioAdmin() {
}

function abreQuestao(codigoQuestao) {
localStorage.setItem(Config.lastLink, "/historico");
navigate('/questoes/codigoquestaohistorico:' + codigoQuestao, { replace: true });
}

Expand Down
34 changes: 19 additions & 15 deletions src/pages/Admin/Logs/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ function Logs(){
buscaDados(value);
};

function formatDate(dateString) {
const date = new Date(dateString);
const day = String(date.getDate()).padStart(2, '0');
const month = String(date.getMonth() + 1).padStart(2, '0');
const year = date.getFullYear();
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');

return `${day}/${month}/${year} ${hours}:${minutes}`;
}

if (loadding) {
return (
<div className='loaddingDiv'>
Expand All @@ -95,20 +106,13 @@ function Logs(){
<h3>Log</h3>
</div>
<div className="separator separator--withMargins"></div>
<div>
<h4>
Id: {logs[index].id}
<br/>
Descrição: {logs[index].descricao}
<br/>
Data de criação: {logs[index].created}
<br/>
Data de atualização: {logs[index].updated}
<br/>
Tipo: {logs[index].tipo}
<br/>
StackTrace: {logs[index].stackTrace}
</h4>
<div className="detalhes-modal-separado">
<h4>Id: {logs[index].id}</h4>
<h4>Descrição: {logs[index].descricao}</h4>
<h4>Data de criação: {formatDate(logs[index].created)}</h4>
<h4>Data de atualização: {formatDate(logs[index].updated)}</h4>
<h4>Tipo: {logs[index].tipo}</h4>
<h4>StackTrace: {logs[index].stackTrace}</h4>
</div>
</div>
</Modal>
Expand Down Expand Up @@ -148,7 +152,7 @@ function Logs(){
</td>
<td>
<h4>
{item.created}
{formatDate(item.created)}
</h4>
</td>
<td className='option'>
Expand Down
48 changes: 30 additions & 18 deletions src/pages/Admin/Usuarios/Usuario.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ function Usuarios(){
buscaDados(value);
};

function formatDate(dateString) {
const date = new Date(dateString);
const day = String(date.getDate()).padStart(2, '0');
const month = String(date.getMonth() + 1).padStart(2, '0');
const year = date.getFullYear();
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');

return `${day}/${month}/${year} ${hours}:${minutes}`;
}

if (loadding) {
return (
<div className='loaddingDiv'>
Expand All @@ -94,24 +105,17 @@ function Usuarios(){
<h3>Log</h3>
</div>
<div className="separator separator--withMargins"></div>
<div className="detalhesModal">
<h4>
Id: {usuarios[index].id}
<br/>
Login: {usuarios[index].login}
<br/>
Nome: {usuarios[index].nome}
<br/>
Email: {usuarios[index].email}
<br/>
Data de nascimento: {usuarios[index].dataNascimento}
<br/>
Foi verificado: {usuarios[index].isVerified}
<br/>
Perfil: {usuarios[index].tipoPerfil?.descricao}
<br/>
Instituicao: {usuarios[index].instituicao}
</h4>
<div className="detalhes-modal-separado">
<h4>Id: {usuarios[index].id}</h4>
<h4>Login: {usuarios[index].login}</h4>
<h4>Nome: {usuarios[index].nome}</h4>
<h4>Email: {usuarios[index].email}</h4>
<h4>Data de nascimento: {usuarios[index].dataNascimento}</h4>
<h4>Foi verificado: {usuarios[index].isVerified == "1" ? "Sim" : "Não"}</h4>
<h4>Perfil: {usuarios[index].tipoPerfil?.descricao}</h4>
<h4>Instituicao: {usuarios[index].instituicao}</h4>
<h4>Criado: {formatDate(usuarios[index].created)}</h4>
<h4>Atualizado: {formatDate(usuarios[index].updated)}</h4>
</div>
</div>
</Modal>
Expand All @@ -132,6 +136,9 @@ function Usuarios(){
<th>
Perfil
</th>
<th>
Criado
</th>
<th>
Verificado
</th>
Expand Down Expand Up @@ -165,6 +172,11 @@ function Usuarios(){
{item.tipoPerfil?.descricao}
</h4>
</td>
<td>
<h4>
{formatDate(item.created)}
</h4>
</td>
<td>
<h4>
{item.isVerified}
Expand Down
1 change: 1 addition & 0 deletions src/pages/Bancas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function Bancas() {
}

buscaBancas();
localStorage.setItem(Config.lastLink, "/bancas");
}, []);

const handleChange = (selectedOptions, event) => {
Expand Down
45 changes: 43 additions & 2 deletions src/pages/CadastroAvaliacao/cadastroAvaliacao.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ content: {
const filtroBanca=1;
const filtroProva=2;
const filtroMateria=3;
const filtroAssuntos=4;

function CadastroAvaliacao(){
const navigate = useNavigate();
Expand All @@ -55,6 +56,8 @@ function CadastroAvaliacao(){
const[selectedMaterias, setSelectedMaterias ] = useState([]);
const[bancas, setBancas] = useState([]);
const[selectedBancas, setSelectedBancas ] = useState([]);
const[assuntos, setAssuntos] = useState([]);
const[selectedAssuntos, setSelectedAssuntos ] = useState([]);
const[filtrando, setFiltrando ] = useState(true);
const[acao, setAcao ] = useState('I');

Expand Down Expand Up @@ -102,18 +105,27 @@ function CadastroAvaliacao(){
useEffect(() => {
buscaDadosFiltro(filtroBanca);
buscaDadosFiltro(filtroMateria);
buscaDadosFiltro(filtroAssuntos);
}, [selectedProvas]);

useEffect(() => {
buscaDadosFiltro(filtroProva);
buscaDadosFiltro(filtroMateria);
buscaDadosFiltro(filtroAssuntos);
}, [selectedBancas]);

useEffect(() => {
buscaDadosFiltro(filtroBanca);
buscaDadosFiltro(filtroProva);
buscaDadosFiltro(filtroAssuntos);
}, [selectedMaterias]);

useEffect(() => {
buscaDadosFiltro(filtroBanca);
buscaDadosFiltro(filtroProva);
buscaDadosFiltro(filtroMateria);
}, [selectedAssuntos]);

function openModalQuestoesAvaliacao() {
setPageQuestoesAvaliacao(1);
setModalQuestoesAvaliacao(true);
Expand All @@ -129,6 +141,7 @@ function CadastroAvaliacao(){
await buscaDadosFiltro(filtroBanca);
await buscaDadosFiltro(filtroProva);
await buscaDadosFiltro(filtroMateria);
await buscaDadosFiltro(filtroAssuntos);

setLoadding(false);

Expand Down Expand Up @@ -194,6 +207,18 @@ function CadastroAvaliacao(){
setSelectedBancas(selectedOptions);
}

const handleChangeSelectAssuntos = async (selectedOptions, event) => {
let temp = [];
selectedOptions.forEach((item) => {
temp.push({
banca: item.value
}
);
})

setSelectedAssuntos(selectedOptions);
}

function montaBusca(){
var retorno = '';

Expand All @@ -218,6 +243,13 @@ function CadastroAvaliacao(){
})
}

if(selectedAssuntos.length > 0){
retorno += "&assuntos="
selectedAssuntos.forEach((i, index) => {
retorno += index > 0 ? ";" + i.value : i.value;
})
}

return retorno;
}

Expand All @@ -230,9 +262,12 @@ function CadastroAvaliacao(){
else if(tipo == filtroProva){
url = '/Prova/GetAllProvasName';
}
else{
else if(tipo == filtroMateria){
url = '/Prova/GetAllMaterias';
}
else{
url = '/Prova/GetAllAssuntos';
}

await api.get(url + '?1=1' + montaBusca())
.then((response) => {
Expand All @@ -251,9 +286,12 @@ function CadastroAvaliacao(){
else if(tipo == filtroProva){
setProvas(t);
}
else{
else if(tipo == filtroMateria){
setMaterias(t);
}
else{
setAssuntos(t);
}
}
else{
navigate('/', {replace: true});
Expand Down Expand Up @@ -469,6 +507,9 @@ function CadastroAvaliacao(){
<h4>Matérias:</h4>
<Select className='tiposProva' closeMenuOnSelect={false} components={animatedComponents} options={materias} value={selectedMaterias} isMulti onChange={handleChangeSelectMateria} />

<h4>Assuntos:</h4>
<Select className='tiposProva' closeMenuOnSelect={false} components={animatedComponents} options={assuntos} value={selectedAssuntos} isMulti onChange={handleChangeSelectAssuntos} />

<div className='botao-filtrar'>
<button className='global-button global-button' onClick={filtrarQuestoes}>Filtrar</button>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/pages/HistoricoUsuario/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function HistoricoUsuario() {
}, [])

function abreQuestao(codigoQuestao) {
localStorage.setItem(Config.lastLink, "/historico");
navigate('/questoes/codigoquestaohistorico:' + codigoQuestao, { replace: true });
}

Expand Down
Loading

0 comments on commit f6f923e

Please sign in to comment.