59
59
</div >
60
60
</div >
61
61
<section class =" sobreMim" >
62
- <h2 >Sobre mim</h2 >
62
+ <h2 >
63
+ Sobre mim
64
+ <div id =" getCurriculo" >
65
+ <button @click =" GetCurriculoFile" v-if =" linkstatus == 0" >Gerar Currículo</button >
66
+ <p v-if =" linkstatus == 1" >Gerando currículo</p >
67
+ <p v-if =" linkstatus == 2" >Currículo gerado</p >
68
+ <a v-if =" linkstatus == 2" >
69
+ <button @click =" downloadFile" >Baixar</button >
70
+ </a >
71
+ </div >
72
+ </h2 >
63
73
<div >
64
74
<p v-show =" mode === 'view'" v-html =" aluno.curriculo" ></p >
65
75
<textarea v-show =" mode === 'edit'" name =" " cols =" 30" rows =" 10" id =" edit"
@@ -176,6 +186,8 @@ import {
176
186
editExtracurricular ,
177
187
deleteExtracurricular ,
178
188
getExtracurriculares ,
189
+ getCurriculoFile
190
+
179
191
} from " ../../services/api/aluno" ;
180
192
import { getImage , getBanner } from " ../../services/api/shared" ;
181
193
import { mixinAluno } from " ../../util/authMixins" ;
@@ -199,9 +211,14 @@ export default {
199
211
email: " " ,
200
212
curriculo: " " ,
201
213
curriculoEdit: " " ,
202
- imgUrl: " default" ,
214
+ token: " " ,
215
+ imgUrl: " ../../assets/img/defaultImage.png" ,
203
216
bannerUrl: " default" ,
217
+ link_curriculo: " "
204
218
},
219
+ file: " " ,
220
+ fileSelected: false ,
221
+ linkstatus: 0 ,
205
222
mode: " view" ,
206
223
modeImage: " view" ,
207
224
modeBanner: " view" ,
@@ -522,6 +539,102 @@ export default {
522
539
}
523
540
},
524
541
542
+ async getData () {
543
+ const response = await getCurriculo (this .aluno .token );
544
+
545
+ try {
546
+ if (response .status >= 200 && response .status < 300 ) {
547
+ this .aluno .curriculo = response .data .curriculo .replace (
548
+ / \n / g ,
549
+ " <br>" ,
550
+ );
551
+ this .aluno .curriculoEdit = response .data .curriculo ;
552
+ this .aluno .endereco = response .data .endereco ;
553
+ this .aluno .nascimento = response .data .nascimento ;
554
+ this .calcularIdade (this .aluno .nascimento );
555
+ this .aluno .nascimento = this .aluno .nascimento
556
+ .split (" T" )[0 ]
557
+ .split (" -" )
558
+ .reverse ()
559
+ .join (" /" );
560
+ this .aluno .nome = response .data .nome ;
561
+ this .aluno .email = response .data .email ;
562
+ this .aluno .rm = response .data .rm ;
563
+ this .aluno .quantidadeVinculos = response .data .quantidadeVinculos ;
564
+ } else {
565
+ alert (
566
+ " Ops.. Algo deu errado ao recuperar os dados. 😕\n " +
567
+ response .message ,
568
+ );
569
+ }
570
+ } catch (error) {
571
+ alert (
572
+ " Ops.. Algo deu errado ao recuperar os dados. 😕\n " + error,
573
+ );
574
+ }
575
+
576
+ try {
577
+ const response = await getImage ({
578
+ identifier: " ALUNO" ,
579
+ email: this .aluno .email ,
580
+ });
581
+
582
+ if (response .status >= 200 && response .status < 300 ) {
583
+ this .aluno .imageUrl = response .data .url ;
584
+ } else {
585
+ console .log (
586
+ " Ops.. Algo deu errado ao recuperar a imagem. 😕\n " +
587
+ response .message ,
588
+ );
589
+ }
590
+ } catch (error) {
591
+ console .log (
592
+ " Ops.. Algo deu errado ao recuperar a imagem de perfil. 😕\n " +
593
+ error,
594
+ );
595
+ }
596
+ },
597
+ async GetCurriculoFile () {
598
+ this .linkstatus = 1 ;
599
+ const response = await getCurriculoFile (this .aluno .token );
600
+
601
+ if (response .status >= 200 && response .status < 300 ) {
602
+ console .log (response);
603
+ this .aluno .link_curriculo = response .data .url ;
604
+
605
+ this .linkstatus = 2 ;
606
+ } else {
607
+ alert (
608
+ " Ops.. Algo deu errado ao gerar currículo. 😕\n " +
609
+ response .message ,
610
+ );
611
+ }
612
+ },
613
+ async downloadFile () {
614
+ try {
615
+ const response = await fetch (this .aluno .link_curriculo );
616
+
617
+ if (! response .ok ) {
618
+ throw new Error (' Falha no download do arquivo.' );
619
+ }
620
+
621
+ const blob = await response .blob ();
622
+
623
+ const blobUrl = window .URL .createObjectURL (blob);
624
+
625
+ const link = document .createElement (' a' );
626
+ link .href = blobUrl;
627
+ link .setAttribute (' download' , ' Curriculo.pdf' );
628
+ document .body .appendChild (link);
629
+ link .click ();
630
+
631
+ window .URL .revokeObjectURL (blobUrl);
632
+ document .body .removeChild (link);
633
+ } catch (error) {
634
+ console .error (' Erro ao baixar o arquivo:' , error);
635
+ }
636
+ },
637
+
525
638
cancelAdd () {
526
639
this .showAddForm = false ;
527
640
this .newActivity = {
0 commit comments