Skip to content

Commit 315fff5

Browse files
Merge pull request #90 from Daniel-Alvarenga/main
Update complete register and generate curriculo
2 parents 24ceb93 + bf99eca commit 315fff5

File tree

18 files changed

+248
-135
lines changed

18 files changed

+248
-135
lines changed

client/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# SERVER_URL="http://localhost:3333"
1+
SERVER_URL="http://localhost:3333"

client/src/router/routes/aluno.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,31 +80,31 @@ export const alunoRoutes = [
8080
name: "Rede",
8181
component: Rede,
8282
beforeEnter: async (to, from, next) => {
83-
(await isAuthAluno()) ? next() : next("/login");
83+
(await isCompletedAluno()) ? ((await isAuthAluno()) ? next() : next("/login")): next("/register/complete");
8484
}
8585
},
8686
{
8787
path: "/mensagens",
8888
name: "Mensagens",
8989
component: Messages,
9090
beforeEnter: async (to, from, next) => {
91-
(await isAuthAluno()) ? next() : next("/login");
91+
(await isCompletedAluno()) ? ((await isAuthAluno()) ? next() : next("/login")) : next("/register/complete");
9292
}
9393
},
9494
{
9595
path: "/mensagens/:identifier/:email",
9696
name: "Mensagem",
9797
component: ChatAluno,
9898
beforeEnter: async (to, from, next) => {
99-
(await isAuthAluno()) ? next() : next("/login");
99+
(await isCompletedAluno()) ? ((await isAuthAluno()) ? next() : next("/login")) : next("/register/complete");
100100
}
101101
},
102102
{
103103
path: "/config",
104104
name: "Config",
105105
component: ConfigAluno,
106106
beforeEnter: async (to, from, next) => {
107-
(await isAuthAluno()) ? next() : next("/login");
107+
(await isCompletedAluno()) ? ((await isAuthAluno()) ? next() : next("/login")) : next("/register/complete");
108108
}
109109
}
110110
];

client/src/views/aluno/Complete.vue

Lines changed: 111 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,58 @@
77
<h1>Termine seu registro</h1>
88

99
<div v-if="etapa === 1" class="step" id="content1">
10-
<h3>Nascimento</h3>
10+
<h3>Dados pessoais</h3>
11+
12+
1113
<li v-if="errorMessage" class="alertBox alertBox-error">{{ errorMessage }}</li>
1214
<div class="input-box" :class="{ 'focused': focused.nascimentoFocused }">
1315
<label for="nascimento">Data de nascimento</label>
1416
<input type="date" id="nascimento" v-model="aluno.nascimento"
1517
@focus="focused.nascimentoFocused = true" @blur="focused.nascimentoFocused = false"
1618
required>
1719
</div>
18-
<span class="alert" v-show="alerts.nascimentoAlert">Por favor, preencha a data de nascimento
19-
corretamente.</span>
20+
21+
<div class="input-box" :class="{ 'focused': focused.telefone }">
22+
<label for="telefone">Telefone ou número de celular</label>
23+
<input type="text" id="telefone" v-model="aluno.telefone" @focus="focused.telefone = true"
24+
@blur="focused.telefone = false" @input="formatTelefone" required>
25+
</div>
26+
27+
<span class="alert" v-show="alerts.nascimentoAlert">Por favor, preencha sua data de nascimento
28+
e número de telefone ou celular corretamente.</span>
2029
<div class="button-box">
2130
<button @click="validateNascimento" type="button">Continuar</button>
2231
</div>
2332
</div>
2433

2534
<div v-if="etapa === 2" class="step" id="content2">
2635
<li v-if="errorMessage" class="alertBox alertBox-error">{{ errorMessage }}</li>
36+
2737
<h3>Endereço</h3>
28-
<Select :dataSelect="dataSelectEstado" @input="$event => updateCidades($event)"/>
29-
<Select :dataSelect="dataSelectCidade" @input="aluno.endereco.cidade = $event"/>
38+
39+
<div class="input-box" :class="{ 'focused': focused.cep }">
40+
<label for="cep">CEP</label>
41+
<input type="text" id="cep" v-model="aluno.endereco.cep" @focus="focused.cep = true"
42+
@blur="focused.cep = false" @input="handleCepInput" required>
43+
</div>
44+
45+
<div class="input-box" :class="{ 'focused': focused.municipio }">
46+
<label for="municipio">Município</label>
47+
<input type="text" id="municipio" :value="aluno.endereco.municipio? (aluno.endereco.municipio + ', ' + aluno.endereco.estado) : ''"
48+
@focus="focused.municipio = true" @blur="focused.municipio = false" readonly>
49+
</div>
50+
51+
<div class="input-box" :class="{ 'focused': focused.rua }">
52+
<label for="rua">Rua</label>
53+
<input type="text" id="rua" v-model="aluno.endereco.rua" @focus="focused.rua = true"
54+
@blur="focused.rua = false" required>
55+
</div>
56+
57+
<div class="input-box" :class="{ 'focused': aluno.numero }">
58+
<label for="numero">Número</label>
59+
<input type="text" id="numero" v-model="aluno.endereco.numero" @focus="focused.numero = true"
60+
@blur="focused.numero = false" required>
61+
</div>
3062

3163
<span class="alert" v-show="alerts.enderecoAlert">Por favor, preencha o endereço corretamente.</span>
3264
<div class="button-box">
@@ -60,7 +92,7 @@
6092

6193
<div v-if="etapa === 5" class="step" id="content5">
6294
<li v-if="errorMessage" class="alertBox alertBox-error">{{ errorMessage }}</li>
63-
<h3>RM</h3>
95+
<h3>Resgistro de Matrícula</h3>
6496
<div class="input-box" :class="{ 'focused': focused.rmFocused }">
6597
<label for="rm">RM</label>
6698
<input type="text" id="rm" v-model="aluno.rm" @focus="focused.rmFocused = true"
@@ -90,6 +122,8 @@ import Select from '../../components/Select.vue';
90122
import { completeRegister, getCursos, getInicios } from '../../services/api/aluno';
91123
import { mixinAluno } from '../../util/authMixins';
92124
125+
import axios from 'axios';
126+
93127
export default {
94128
name: 'Complete',
95129
components: {
@@ -101,11 +135,15 @@ export default {
101135
return {
102136
aluno: {
103137
email: '',
138+
telefone: '',
104139
nascimento: '',
105140
rm: '',
106141
endereco: {
107-
cidade: '',
108-
estado: ''
142+
cep: '',
143+
municipio: '',
144+
estado: '',
145+
rua: '',
146+
numero: ''
109147
},
110148
curso: {
111149
name: '',
@@ -114,8 +152,6 @@ export default {
114152
}
115153
},
116154
etapa: 1,
117-
ufs: ['SP'],
118-
cidades: [],
119155
cursos: [],
120156
inicios: [],
121157
focused: {
@@ -133,16 +169,6 @@ export default {
133169
inicioAlert: false,
134170
rmAlert: false
135171
},
136-
dataSelectEstado:{
137-
title: "Selecione o estado",
138-
description: "UF",
139-
options: [],
140-
},
141-
dataSelectCidade:{
142-
title: "Selecione sua cidade",
143-
description: "Município",
144-
options: [],
145-
},
146172
dataSelectTurno: {
147173
title: "Selecione um turno",
148174
description: "Turno",
@@ -169,14 +195,28 @@ export default {
169195
},
170196
computed: {
171197
allRequirementsMet() {
172-
return this.aluno.nascimento && this.aluno.endereco.estado && this.aluno.endereco.cidade &&
173-
this.aluno.curso.name && this.aluno.curso.turno && this.aluno.curso.inicio && this.aluno.rm;
198+
return this.aluno.nascimento &&
199+
this.aluno.endereco.estado !== '' &&
200+
this.aluno.endereco.municipio !== '' &&
201+
this.aluno.endereco.rua !== '' &&
202+
this.aluno.endereco.numero !== '' &&
203+
this.aluno.endereco.cep !== '' &&
204+
this.aluno.curso.name !== '' &&
205+
this.aluno.curso.turno !== '' &&
206+
this.aluno.curso.inicio !== '' &&
207+
this.aluno.rm !== '' &&
208+
this.aluno.telefone !== '';
174209
},
175210
nascimentoValidated() {
176-
return this.aluno.nascimento !== '';
211+
return this.aluno.nascimento !== '' &&
212+
this.aluno.telefone !== '';
177213
},
178214
enderecoValidated() {
179-
return this.aluno.endereco.estado !== '' && this.aluno.endereco.cidade !== '';
215+
return this.aluno.endereco.estado !== '' &&
216+
this.aluno.endereco.municipio !== '' &&
217+
this.aluno.endereco.rua !== '' &&
218+
this.aluno.endereco.numero !== '' &&
219+
this.aluno.endereco.cep !== '';
180220
},
181221
inicioValidated() {
182222
return this.aluno.curso.inicio !== '';
@@ -187,7 +227,8 @@ export default {
187227
try {
188228
const response = await completeRegister({
189229
rm: this.aluno.rm,
190-
endereco: this.aluno.endereco.cidade + ", " + this.aluno.endereco.estado,
230+
telefone: this.aluno.telefone,
231+
endereco: this.aluno.endereco,
191232
nascimento: this.aluno.nascimento,
192233
curso: this.aluno.curso.name,
193234
inicio: this.aluno.curso.inicio
@@ -259,23 +300,6 @@ export default {
259300
this.alerts.inicioAlert = true;
260301
}
261302
},
262-
async updateEstados() {
263-
this.dataSelectEstado.options = this.ufs.map(uf => ({
264-
value: uf,
265-
description: uf
266-
}));
267-
},
268-
async updateCidades(estadoSeleted) {
269-
this.aluno.endereco.estado = estadoSeleted;
270-
const estado = this.aluno.endereco.estado;
271-
if (estado === 'SP') {
272-
this.cidades = ['São Paulo', 'Santo André', 'São Bernardo', 'São Caetano', 'Diadema', 'Mauá', 'Ribeirão Pires', 'Rio Grande da Serra'];
273-
this.dataSelectCidade.options = this.cidades.map(cidade => ({
274-
value: cidade,
275-
description: cidade
276-
}))
277-
}
278-
},
279303
async fetchCursos() {
280304
try {
281305
const response = await getCursos(this.aluno.token);
@@ -292,14 +316,57 @@ export default {
292316
} catch (error) {
293317
this.errorMessage = "Ops.. Algo deu errado ao buscar os cursos. 😕";
294318
}
295-
}
319+
},
320+
formatTelefone() {
321+
let telefone = this.aluno.telefone.replace(/\D/g, '');
322+
if (telefone.length > 11) {
323+
telefone = telefone.substring(0, 11);
324+
}
325+
if (telefone.length > 10) {
326+
telefone = telefone.replace(/^(\d{2})(\d{5})(\d{4})/, '($1) $2-$3');
327+
} else if (telefone.length > 9) {
328+
telefone = telefone.replace(/^(\d{2})(\d{4})(\d{4})/, '($1) $2-$3');
329+
}
330+
this.aluno.telefone = telefone;
331+
},
332+
async loadDataFromCep() {
333+
const cep = this.aluno.endereco.cep.replace(/\D/g, '');
334+
if (cep.length === 8) {
335+
try {
336+
const response = await axios.get(`https://viacep.com.br/ws/${cep}/json/`);
337+
if (response.data) {
338+
this.aluno.endereco.municipio = response.data.localidade;
339+
this.aluno.endereco.estado = response.data.uf;
340+
this.aluno.endereco.rua = response.data.logradouro;
341+
}
342+
} catch (error) {
343+
console.error("Erro ao buscar dados do CEP:", error);
344+
}
345+
}
346+
},
347+
formatCep(cep) {
348+
cep = cep.replace(/\D/g, '');
349+
if (cep.length > 8) {
350+
cep = cep.substring(0, 8);
351+
}
352+
if (cep.length > 5) {
353+
cep = cep.replace(/^(\d{5})(\d)/, '$1-$2');
354+
}
355+
return cep;
356+
},
357+
handleCepInput(event) {
358+
const input = event.target.value;
359+
this.aluno.endereco.cep = this.formatCep(input);
360+
if (input.replace(/\D/g, '').length === 8) {
361+
this.loadDataFromCep();
362+
}
363+
},
296364
},
297365
mixins: [mixinAluno],
298366
async created() {
299367
await this.getToken();
300368
this.aluno.email = Cookies.get('email-aluno');
301369
this.fetchCursos();
302-
this.updateEstados();
303370
}
304371
};
305372
</script>

client/src/views/aluno/Config.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<h3>Seus dados</h3>
3030

3131
<div id="getCurriculo">
32-
<button @click="GetCurriculoFile" v-if="linkstatus == 0">Gerar Currículo</button>
32+
<button @click="GetCurriculoFile" v-if="linkstatus == 0">Exportar Currículo</button>
3333
<p v-if="linkstatus == 1">Gerando currículo</p>
3434
<p v-if="linkstatus == 2">Currículo gerado</p>
3535
<a v-if="linkstatus == 2">
@@ -48,7 +48,9 @@
4848
</li>
4949
<li>
5050
<bold>Endereço</bold>
51-
<p v-text="aluno.endereco"></p>
51+
<p v-text="'CEP: ' + JSON.parse(aluno.endereco).cep"></p>
52+
<p v-text="JSON.parse(aluno.endereco).rua + ', Nº ' + JSON.parse(aluno.endereco).numero"></p>
53+
<p v-text="JSON.parse(aluno.endereco).municipio + ', ' + JSON.parse(aluno.endereco).estado"></p>
5254
</li>
5355
<li>
5456
<bold>Nascimento</bold>
@@ -68,7 +70,7 @@
6870
<div class="info">
6971
<h3 v-text="aluno.nome"></h3>
7072
<p v-text="aluno.idade"></p>
71-
<p v-text="aluno.endereco"></p>
73+
<p v-text="JSON.parse(aluno.endereco).municipio + ', ' + JSON.parse(aluno.endereco).estado"></p>
7274
</div>
7375
</router-link>
7476
</div>

client/src/views/aluno/Home.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
<div class="info">
6565
<h3 v-text="aluno.nome"></h3>
6666
<p v-text="aluno.idade"></p>
67-
<p v-text="aluno.endereco"></p>
6867
</div>
6968
</router-link>
7069
<div class="vinculos">
@@ -107,7 +106,6 @@ export default {
107106
aluno: {
108107
token: '',
109108
nome: '',
110-
endereco: '',
111109
nascimento: '',
112110
idade: '',
113111
email: '',

client/src/views/aluno/Profile.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
</div>
5454
<div class="box2">
5555
<p v-text="aluno.idade"></p>
56-
<p v-text="aluno.endereco"></p>
56+
<p v-text="JSON.parse(aluno.endereco).municipio + ', ' + JSON.parse(aluno.endereco).estado"></p>
5757
</div>
5858
</div>
5959
</div>
@@ -396,6 +396,9 @@ export default {
396396
397397
if (response.status >= 200 && response.status < 300) {
398398
alert("Imagem de perfil atualizada com sucesso! 😉");
399+
400+
this.linkstatus = 0;
401+
399402
await this.getCurriculoAluno();
400403
} else {
401404
alert(
@@ -480,6 +483,8 @@ export default {
480483
this.aluno.token,
481484
);
482485
if (response.status >= 200 && response.status < 300) {
486+
this.linkstatus = 0;
487+
483488
alert("Atividade atualizada com sucesso! 😉");
484489
this.fetchExtracurriculares();
485490
} else {
@@ -507,6 +512,9 @@ export default {
507512
);
508513
if (response.status >= 200 && response.status < 300) {
509514
alert("Atividade excluída com sucesso! 😉");
515+
516+
this.linkstatus = 0;
517+
510518
this.extracurriculares.splice(index, 1);
511519
} else {
512520
alert(
@@ -530,6 +538,8 @@ export default {
530538
inicio: "",
531539
fim: "",
532540
};
541+
542+
this.linkstatus = 0;
533543
this.fetchExtracurriculares();
534544
} else {
535545
alert(

client/src/views/shared/PerfilAluno.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</div>
1919
<div class="box2">
2020
<p v-text="aluno.idade"></p>
21-
<p v-text="aluno.endereco"></p>
21+
<p v-text="JSON.parse(aluno.endereco).municipio + ', ' + JSON.parse(aluno.endereco).estado"></p>
2222
<button
2323
v-show="!visualizador.conected && !visualizador.isOwner && !visualizador.semiconectado"
2424
@click="sendSolicitation">Vincular-se</button>

0 commit comments

Comments
 (0)