Skip to content

Commit 96a0fea

Browse files
Merge pull request VitorCarvalho67#22 from Daniel-Alvarenga/main
Update on the Aluno's network pages and public profile and integratio…
2 parents 6200763 + b384346 commit 96a0fea

File tree

10 files changed

+994
-143
lines changed

10 files changed

+994
-143
lines changed

client/package-lock.json

+108-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/src/services/api/aluno.js

+8
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,14 @@ export const getVinculosProfileAluno = async (info, token) => {
201201
authorization: `${token}`
202202
}
203203
});
204+
205+
socket.emit(
206+
'vinculo-enter-aluno',
207+
{
208+
authorization: `${token}`
209+
}
210+
);
211+
204212
return response;
205213
} catch (error) {
206214
return error.data;

client/src/views/aluno/Rede.vue

+39-10
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
<div v-if="vinculo.data.aluno">
1111
<router-link :to="'/aluno/profile/' + vinculo.data.aluno.rm">{{ vinculo.data.aluno.nome }}</router-link>
1212
<p>{{ vinculo.data.aluno.endereco }}</p>
13+
<button @click="removeVinculo(vinculo.data.aluno.email, vinculo.info)">Remover vínculo</button>
1314
</div>
1415
<div v-else-if="vinculo.data.professor">
1516
<p>{{ vinculo.data.professor.nome }}</p>
1617
<p>{{ vinculo.data.professor.titulo }}</p>
18+
<button @click="removeVinculo(vinculo.data.professor.email, vinculo.info)">Remover vínculo</button>
1719
</div>
1820
</div>
1921
</li>
@@ -64,10 +66,8 @@ import Footer from '../../components/Footer.vue';
6466
import router from '../../router/index.js';
6567
import Cookies from 'js-cookie';
6668
import {
67-
getCurriculo,
68-
getMeAluno,
69-
updateCurriculo,
7069
getVinculosAluno,
70+
acceptVinculoAluno,
7171
removeVinculoAluno,
7272
rejectVinculoAluno
7373
} from '../../services/api/aluno';
@@ -124,7 +124,7 @@ export default {
124124
senderIdentifier: info.senderIdentifier,
125125
recipientIdentifier: info.recipientIdentifier
126126
},
127-
this.aluno.email,
127+
info.sender,
128128
this.aluno.token
129129
);
130130
@@ -139,10 +139,9 @@ export default {
139139
},
140140
async removeSolicitation(agent, info) {
141141
try {
142-
let infoVinculo;
143142
let response;
144143
145-
infoVinculo = {
144+
const infoVinculo = {
146145
sender: info.sender,
147146
recipient: info.recipient,
148147
senderIdentifier: info.senderIdentifier,
@@ -152,24 +151,54 @@ export default {
152151
if (agent == "sender") {
153152
response = await removeVinculoAluno(
154153
infoVinculo,
155-
this.aluno.email,
154+
info.recipient,
156155
this.aluno.token
157156
);
158157
} else if (agent == "recipient") {
159158
response = await rejectVinculoAluno(
160159
infoVinculo,
161-
this.aluno.email,
160+
info.sender,
162161
this.aluno.token
163162
);
164163
}
165164
166165
if (response.status >= 200 && response.status < 300) {
167166
await this.getVinculos();
168167
} else {
169-
alert("Ops.. Algo deu errado ao remover o pedido, tente novamente mais tarde. 😕\n" + response.message);
168+
alert(
169+
agent == "sender"?
170+
"Ops.. Algo deu errado ao remover o pedido, tente novamente mais tarde. 😕\n" + response.message:
171+
"Ops.. Algo deu errado ao ignorar o pedido, tente novamente mais tarde. 😕\n" + response.message
172+
);
173+
}
174+
} catch (error) {
175+
alert(
176+
agent == "sender"?
177+
"Ops.. Algo deu errado ao remover o pedido, tente novamente mais tarde. 😕\n" + response.message:
178+
"Ops.. Algo deu errado ao ignorar o pedido, tente novamente mais tarde. 😕\n" + response.message
179+
);
180+
}
181+
},
182+
async removeVinculo(affected, info) {
183+
try {
184+
const response = await removeVinculoAluno(
185+
{
186+
sender: info.sender,
187+
recipient: info.recipient,
188+
senderIdentifier: info.senderIdentifier,
189+
recipientIdentifier: info.recipientIdentifier
190+
},
191+
affected,
192+
this.aluno.token
193+
);
194+
195+
if (response.status >= 200 && response.status < 300) {
196+
await this.getVinculos();
197+
} else {
198+
alert("Ops.. Algo deu errado ao remover esse vínculo, tente novamente mais tarde. 😕\n" + response.message);
170199
}
171200
} catch (error) {
172-
alert("Ops.. Algo deu errado ao remover o pedido, tente novamente mais tarde. 😕\n" + error);
201+
alert("Ops.. Algo deu errado ao remover esse vínculo, tente novamente mais tarde. 😕\n" + error);
173202
}
174203
}
175204
},

client/src/views/shared/PerfilAluno.vue

+32-29
Original file line numberDiff line numberDiff line change
@@ -267,16 +267,13 @@ export default {
267267
}
268268
}
269269
270-
let infoVinculo;
271-
272-
infoVinculo = {
273-
sender: this.aluno.email,
274-
recipient: responseMail.data.email,
275-
senderIdentifier: "ALUNO",
276-
recipientIdentifier: "ALUNO"
277-
}
278270
const response = await acceptVinculoAluno(
279-
infoVinculo,
271+
{
272+
sender: this.aluno.email,
273+
recipient: responseMail.data.email,
274+
senderIdentifier: "ALUNO",
275+
recipientIdentifier: "ALUNO"
276+
},
280277
this.aluno.email,
281278
this.visualizador.token
282279
);
@@ -307,30 +304,27 @@ export default {
307304
}
308305
}
309306
310-
let infoVinculo;
311307
let response;
312308
313309
if (agent == "sender") {
314-
infoVinculo = {
315-
sender: responseMail.data.email,
316-
recipient: this.aluno.email,
317-
senderIdentifier: "ALUNO",
318-
recipientIdentifier: "ALUNO"
319-
}
320310
response = await removeVinculoAluno(
321-
infoVinculo,
311+
{
312+
sender: responseMail.data.email,
313+
recipient: this.aluno.email,
314+
senderIdentifier: "ALUNO",
315+
recipientIdentifier: "ALUNO"
316+
},
322317
this.aluno.email,
323318
this.visualizador.token
324319
);
325320
} else if (agent == "recipient") {
326-
infoVinculo = {
327-
sender: this.aluno.email,
328-
recipient: responseMail.data.email,
329-
senderIdentifier: "ALUNO",
330-
recipientIdentifier: "ALUNO"
331-
}
332321
response = await rejectVinculoAluno(
333-
infoVinculo,
322+
{
323+
sender: this.aluno.email,
324+
recipient: responseMail.data.email,
325+
senderIdentifier: "ALUNO",
326+
recipientIdentifier: "ALUNO"
327+
},
334328
this.aluno.email,
335329
this.visualizador.token
336330
);
@@ -339,11 +333,19 @@ export default {
339333
if (response.status >= 200 && response.status < 300) {
340334
await this.possuiVinculo();
341335
} else {
342-
alert("Ops.. Algo deu errado ao remover o pedido, tente novamente mais tarde. 😕\n" + response.message);
343-
}
344-
} catch (error) {
345-
alert("Ops.. Algo deu errado ao remover o pedido, tente novamente mais tarde. 😕\n" + error);
346-
}
336+
alert(
337+
agent == "sender"?
338+
"Ops.. Algo deu errado ao remover o pedido, tente novamente mais tarde. 😕\n" + response.message:
339+
"Ops.. Algo deu errado ao ignorar o pedido, tente novamente mais tarde. 😕\n" + response.message
340+
);
341+
}
342+
} catch (error) {
343+
alert(
344+
agent == "sender"?
345+
"Ops.. Algo deu errado ao remover o pedido, tente novamente mais tarde. 😕\n" + response.message:
346+
"Ops.. Algo deu errado ao ignorar o pedido, tente novamente mais tarde. 😕\n" + response.message
347+
);
348+
}
347349
}
348350
}
349351
}
@@ -357,6 +359,7 @@ export default {
357359
console.log(this.conected);
358360
359361
socket.on('vinculo-update', async (data) => {
362+
console.log("VINC UDATE");
360363
await this.possuiVinculo();
361364
});
362365
}

0 commit comments

Comments
 (0)