Skip to content

Commit

Permalink
bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
dmartinezbaselga committed May 30, 2019
1 parent 203b731 commit a75e878
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
11 changes: 8 additions & 3 deletions app/src/components/AdministradorCrear.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,14 @@ class AdministradorCrear extends Component {
if (uni !== -1) {
const subj = this.nombreAsig.current.value;
const shortname = this.nombreCortoAsig.current.value;
crearAsigYLigar(this.SubjectApi, subj, shortname, uni);
form.reset();
this.handleShow();
crearAsigYLigar(
this.SubjectApi,
subj,
shortname,
uni,
form,
this.handleShow
);
}
}
/**
Expand Down
14 changes: 11 additions & 3 deletions app/src/config/AdminAPI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,14 @@ function ligarUniCarr(uniID, carreraID, DegreeApi) {
* @param {String} shortname Nombre abreviado de la asignatura
* @param {Number} uni ID de la universidad
*/
export function crearAsigYLigar(SubjectApi, subject, shortname, uni) {
export function crearAsigYLigar(
SubjectApi,
subject,
shortname,
uni,
form,
handleShow
) {
// Configure Bearer (JWT) access token for authorization: bearerAuth
let bearerAuth = defaultClient.authentications["bearerAuth"];
bearerAuth.accessToken = getUserToken();
Expand All @@ -273,7 +280,6 @@ export function crearAsigYLigar(SubjectApi, subject, shortname, uni) {
if (error) {
console.error(error);
} else {
console.log(data);
data._embedded.subjects.forEach(element => {
if (element.university !== undefined && element.university.id === uni) {
encontrado = true;
Expand All @@ -283,6 +289,7 @@ export function crearAsigYLigar(SubjectApi, subject, shortname, uni) {
}
if (encontrado) {
alert("La asignatura ya existía para esa universidad");
form.reset();
} else {
let subject2 = new Subject2(subject, shortname.substr(0, 5)); // Subject2 | Asignatura a añadir
SubjectApi.addSubject(subject2, (error, data, response) => {
Expand All @@ -300,7 +307,6 @@ export function crearAsigYLigar(SubjectApi, subject, shortname, uni) {
if (error) {
console.error(error);
} else {
console.log(data);
let id = 0;
data._embedded.subjects.forEach(element => {
if (element.university === undefined) {
Expand All @@ -314,6 +320,8 @@ export function crearAsigYLigar(SubjectApi, subject, shortname, uni) {
ligarUniAsig(uni, data.id, SubjectApi);
}
});
form.reset();
handleShow();
}
});
}
Expand Down

0 comments on commit a75e878

Please sign in to comment.