Skip to content

Commit

Permalink
Update on the Aluno's network pages and public profile and integratio…
Browse files Browse the repository at this point in the history
…n of websockets on them
  • Loading branch information
Daniel-Alvarenga committed Jun 14, 2024
1 parent 6200763 commit b384346
Show file tree
Hide file tree
Showing 10 changed files with 994 additions and 143 deletions.
115 changes: 108 additions & 7 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions client/src/services/api/aluno.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ export const getVinculosProfileAluno = async (info, token) => {
authorization: `${token}`
}
});

socket.emit(
'vinculo-enter-aluno',
{
authorization: `${token}`
}
);

return response;
} catch (error) {
return error.data;
Expand Down
49 changes: 39 additions & 10 deletions client/src/views/aluno/Rede.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
<div v-if="vinculo.data.aluno">
<router-link :to="'/aluno/profile/' + vinculo.data.aluno.rm">{{ vinculo.data.aluno.nome }}</router-link>
<p>{{ vinculo.data.aluno.endereco }}</p>
<button @click="removeVinculo(vinculo.data.aluno.email, vinculo.info)">Remover vínculo</button>
</div>
<div v-else-if="vinculo.data.professor">
<p>{{ vinculo.data.professor.nome }}</p>
<p>{{ vinculo.data.professor.titulo }}</p>
<button @click="removeVinculo(vinculo.data.professor.email, vinculo.info)">Remover vínculo</button>
</div>
</div>
</li>
Expand Down Expand Up @@ -64,10 +66,8 @@ import Footer from '../../components/Footer.vue';
import router from '../../router/index.js';
import Cookies from 'js-cookie';
import {
getCurriculo,
getMeAluno,
updateCurriculo,
getVinculosAluno,
acceptVinculoAluno,
removeVinculoAluno,
rejectVinculoAluno
} from '../../services/api/aluno';
Expand Down Expand Up @@ -124,7 +124,7 @@ export default {
senderIdentifier: info.senderIdentifier,
recipientIdentifier: info.recipientIdentifier
},
this.aluno.email,
info.sender,
this.aluno.token
);
Expand All @@ -139,10 +139,9 @@ export default {
},
async removeSolicitation(agent, info) {
try {
let infoVinculo;
let response;
infoVinculo = {
const infoVinculo = {
sender: info.sender,
recipient: info.recipient,
senderIdentifier: info.senderIdentifier,
Expand All @@ -152,24 +151,54 @@ export default {
if (agent == "sender") {
response = await removeVinculoAluno(
infoVinculo,
this.aluno.email,
info.recipient,
this.aluno.token
);
} else if (agent == "recipient") {
response = await rejectVinculoAluno(
infoVinculo,
this.aluno.email,
info.sender,
this.aluno.token
);
}
if (response.status >= 200 && response.status < 300) {
await this.getVinculos();
} else {
alert("Ops.. Algo deu errado ao remover o pedido, tente novamente mais tarde. 😕\n" + response.message);
alert(
agent == "sender"?
"Ops.. Algo deu errado ao remover o pedido, tente novamente mais tarde. 😕\n" + response.message:
"Ops.. Algo deu errado ao ignorar o pedido, tente novamente mais tarde. 😕\n" + response.message
);
}
} catch (error) {
alert(
agent == "sender"?
"Ops.. Algo deu errado ao remover o pedido, tente novamente mais tarde. 😕\n" + response.message:
"Ops.. Algo deu errado ao ignorar o pedido, tente novamente mais tarde. 😕\n" + response.message
);
}
},
async removeVinculo(affected, info) {
try {
const response = await removeVinculoAluno(
{
sender: info.sender,
recipient: info.recipient,
senderIdentifier: info.senderIdentifier,
recipientIdentifier: info.recipientIdentifier
},
affected,
this.aluno.token
);
if (response.status >= 200 && response.status < 300) {
await this.getVinculos();
} else {
alert("Ops.. Algo deu errado ao remover esse vínculo, tente novamente mais tarde. 😕\n" + response.message);
}
} catch (error) {
alert("Ops.. Algo deu errado ao remover o pedido, tente novamente mais tarde. 😕\n" + error);
alert("Ops.. Algo deu errado ao remover esse vínculo, tente novamente mais tarde. 😕\n" + error);
}
}
},
Expand Down
61 changes: 32 additions & 29 deletions client/src/views/shared/PerfilAluno.vue
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,13 @@ export default {
}
}
let infoVinculo;
infoVinculo = {
sender: this.aluno.email,
recipient: responseMail.data.email,
senderIdentifier: "ALUNO",
recipientIdentifier: "ALUNO"
}
const response = await acceptVinculoAluno(
infoVinculo,
{
sender: this.aluno.email,
recipient: responseMail.data.email,
senderIdentifier: "ALUNO",
recipientIdentifier: "ALUNO"
},
this.aluno.email,
this.visualizador.token
);
Expand Down Expand Up @@ -307,30 +304,27 @@ export default {
}
}
let infoVinculo;
let response;
if (agent == "sender") {
infoVinculo = {
sender: responseMail.data.email,
recipient: this.aluno.email,
senderIdentifier: "ALUNO",
recipientIdentifier: "ALUNO"
}
response = await removeVinculoAluno(
infoVinculo,
{
sender: responseMail.data.email,
recipient: this.aluno.email,
senderIdentifier: "ALUNO",
recipientIdentifier: "ALUNO"
},
this.aluno.email,
this.visualizador.token
);
} else if (agent == "recipient") {
infoVinculo = {
sender: this.aluno.email,
recipient: responseMail.data.email,
senderIdentifier: "ALUNO",
recipientIdentifier: "ALUNO"
}
response = await rejectVinculoAluno(
infoVinculo,
{
sender: this.aluno.email,
recipient: responseMail.data.email,
senderIdentifier: "ALUNO",
recipientIdentifier: "ALUNO"
},
this.aluno.email,
this.visualizador.token
);
Expand All @@ -339,11 +333,19 @@ export default {
if (response.status >= 200 && response.status < 300) {
await this.possuiVinculo();
} else {
alert("Ops.. Algo deu errado ao remover o pedido, tente novamente mais tarde. 😕\n" + response.message);
}
} catch (error) {
alert("Ops.. Algo deu errado ao remover o pedido, tente novamente mais tarde. 😕\n" + error);
}
alert(
agent == "sender"?
"Ops.. Algo deu errado ao remover o pedido, tente novamente mais tarde. 😕\n" + response.message:
"Ops.. Algo deu errado ao ignorar o pedido, tente novamente mais tarde. 😕\n" + response.message
);
}
} catch (error) {
alert(
agent == "sender"?
"Ops.. Algo deu errado ao remover o pedido, tente novamente mais tarde. 😕\n" + response.message:
"Ops.. Algo deu errado ao ignorar o pedido, tente novamente mais tarde. 😕\n" + response.message
);
}
}
}
}
Expand All @@ -357,6 +359,7 @@ export default {
console.log(this.conected);
socket.on('vinculo-update', async (data) => {
console.log("VINC UDATE");
await this.possuiVinculo();
});
}
Expand Down
Loading

0 comments on commit b384346

Please sign in to comment.