Commit 2b393ddb authored by Matheus Horstmann's avatar Matheus Horstmann 🐴

Merge branch 'bugs_aleatorios' into 'develop'

bugs aleatorios

See merge request !23
parents 1cadb661 e4cfc371
Pipeline #22739 failed with stages
in 1 minute and 11 seconds
......@@ -150,8 +150,6 @@ export function CustTable(props) {
const classes = useStyles(props);
const optionsNumber = (props.options_number)? props.options_number : 10;
const [selected, setSelected] = React.useState([]);
if(rows[0])
console.log("value: ",rows[0].codigo)
const a = (rows[0] )? get_table_cache(rows[0].codigo) : 0
const [page, setPage] = React.useState(a);
const [rowsPerPage, setRowsPerPage] = React.useState(optionsNumber);
......
......@@ -357,7 +357,7 @@ export function Sala(props) {
<Grid container justify="flex-end" spacing={2} direction="column">
<div>
<Grid item >
<HeaderSala nome_curso={bloco.nome}></HeaderSala>
<HeaderSala nome_curso={(bloco)?bloco.nome:""}></HeaderSala>
</Grid>
<Grid item xs={12} md={12} sm={12}>
<ListSala salas={props.salas} bloco={bloco}/>
......
......@@ -219,6 +219,7 @@ export function MenuInfo(props) {
const {turma_select, setTurmaSelected} = useContext(TurmaSelect);
const [_turma, _setTurma] = useState(turma_select);
const {object_query} = useContext(ObjectsQuery);
const {turma_list, setTurmaList, delTurmaList} = useContext(TurmaList);
const handleChange = name => event => {
_setTurma({ ..._turma, [name]: event.target.value });
};
......@@ -239,6 +240,11 @@ export function MenuInfo(props) {
evt.preventDefault()
setTurmaSelected(_turma);
console.log("_turma: ",_turma)
if( _turma.id) {
var _turmas = turma_list
_turmas[_turma.id] = _turma
setTurmaList(_turmas)
}
}
return (
<form onSubmit={handleSubmit} >
......@@ -408,7 +414,19 @@ export function Horario(props) {
var response=false;
if (turma_select) {
var _t = turma_select;
_t.horarios.push(_horario)
if( _t.horarios)
_t.horarios.push(_horario)
else
_t.horarios = [_horario]
var is_update = -1
for(var i=0; i<_t.horarios.length; i++) {
if(_t.horarios[i].id == _horario.id)
is_update = i
}
if(is_update >= 0)
_t.horarios[is_update] = _horario
else
_t.horarios.push(_horario)
setTurmaSelected(_t);
}
......@@ -740,6 +758,7 @@ export function Menu(props) {
const {turma_select, setTurmaSelect} = useContext(TurmaSelect);
const [info, setInfo] = useState({});
const {change,setChange} = useContext(Change)
const {object_query} = useContext(ObjectsQuery);
const {message_active,setMessageActive} = React.useContext(MessageActive)
const {message,setMessage} = React.useContext(Messages);
......@@ -748,6 +767,10 @@ export function Menu(props) {
try {
var t = turma_select
if(t.disciplina && t.disciplina)
t.departamentoCod = t.disciplina.departamentoCod
else
t.departamentoCod = object_query.disciplinas[t.disciplinaCod].departamentoCod
// cria ou atualiza turma
try {
const response = await api.put("turmas/create_turma",{"turma":t});
......@@ -757,21 +780,20 @@ export function Menu(props) {
} catch (e) {
setMessage("Erro ao submeter turma: "+e);
setMessageActive(true);
/* handle error */
}
// cria ou atualiza os horarios da turma
for(var i=0; i < t.horarios.length; i++) {
var horario = t.horarios[i]
var _response = send_horario(t,horario);
if (_response) {
setMessage("Erro ao submeter horario, verifique o formulário ou entre em contato com os desenvolvedores");
setMessageActive(true);
} else {
setMessage("Horario submetido com sucesso");
setMessageActive(true);
}
//for(var i=0; i < t.horarios.length; i++) {
// var horario = t.horarios[i]
// var _response = await send_horario(t,horario);
// if (_response) {
// setMessage("Erro ao submeter horario, verifique o formulário ou entre em contato com os desenvolvedores");
// setMessageActive(true);
// } else {
// setMessage("Horario submetido com sucesso");
// setMessageActive(true);
// }
}
//}
} catch (e) {
setMessage("Erro ao submeter turma: "+e);
setMessageActive(true);
......@@ -879,7 +901,7 @@ export function GerenciarTurma (props) {
}
};
fetchData();});
fetchData();},[]);
const [disciplina_filtered, setDisciplinaFiltered] = React.useState({})
useEffect(() => {
var disciplinas_tmp = {}
......
export function set_query_cache(name,value) {
return localStorage.setItem(name,value);
return sessionStorage.setItem(name,value);
}
export function get_query_cache(name) {
return (localStorage.getItem(name))? localStorage.getItem(name) : ""
return (sessionStorage.getItem(name))? sessionStorage.getItem(name) : ""
}
export function set_table_cache(name,value) {
console.log("funcao set_table_cache ", name,value)
return sessionStorage.setItem(name,value);
}
export function get_table_cache(name) {
var result = (sessionStorage.getItem(name))? sessionStorage.getItem(name) : 0
console.log("funcao get_table_cache ", name, result)
return result
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment