Skip to content

Commit ce0722b

Browse files
Add generate curriculum func
1 parent ac6219d commit ce0722b

File tree

11 files changed

+1214
-79
lines changed

11 files changed

+1214
-79
lines changed

client/src/services/api/aluno.js

+13
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,19 @@ export const getCurriculo = async (token) => {
250250
}
251251
}
252252

253+
export const getCurriculoFile = async (token) => {
254+
try {
255+
const response = await api.get('aluno/curriculo/download', {
256+
headers: {
257+
authorization: `${token}`
258+
}
259+
});
260+
return response;
261+
} catch (error) {
262+
return error.data;
263+
}
264+
}
265+
253266
export const getMeAluno = async (token) => {
254267
try {
255268
const response = await api.get('aluno/me', {

client/src/views/aluno/Config.vue

+52-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
Configure seu perfil e veja suas informações
1010
</h2>
1111

12+
<div id="getCurriculo">
13+
<button @click="GetCurriculoFile" v-if="linkstatus == 0">Gerar Currículo</button>
14+
<p v-if="linkstatus == 1">Gerando currículo</p>
15+
<p v-if="linkstatus == 2">Currículo gerado</p>
16+
<a v-if="linkstatus == 2">
17+
<button @click="downloadFile">Baixar</button>
18+
</a>
19+
</div>
20+
1221
<h3>Envio de boletim</h3>
1322

1423
<div class="inputUpload">
@@ -69,7 +78,7 @@ import Header from "../../components/aluno/Header.vue";
6978
import AsideDashboard from "../../components/aluno/AsideDashboard.vue";
7079
import Footer from "../../components/Footer.vue";
7180
72-
import { getCurriculo, sendBoletim } from "../../services/api/aluno";
81+
import { getCurriculo, getCurriculoFile, sendBoletim } from "../../services/api/aluno";
7382
import { getImage } from "../../services/api/shared";
7483
7584
import imgVerificar from "../../assets/icons/verificar.png";
@@ -96,9 +105,11 @@ export default {
96105
curriculoEdit: "",
97106
imgUrl: "../../assets/img/defaultImage.png",
98107
bannerUrl: "../../assets/img/defaultBanner.png",
108+
link_curriculo: ""
99109
},
100110
file: "",
101111
fileSelected: false,
112+
linkstatus: 0
102113
};
103114
},
104115
methods: {
@@ -201,6 +212,46 @@ export default {
201212
this.file = this.$refs.boletimInput.files[0];
202213
};
203214
},
215+
async GetCurriculoFile(){
216+
this.linkstatus = 1;
217+
const response = await getCurriculoFile(this.aluno.token);
218+
219+
if (response.status >= 200 && response.status < 300) {
220+
console.log(response);
221+
this.aluno.link_curriculo = response.data.url;
222+
223+
this.linkstatus = 2;
224+
} else {
225+
alert(
226+
"Ops.. Algo deu errado ao gerar currículo. 😕\n" +
227+
response.message,
228+
);
229+
}
230+
},
231+
async downloadFile() {
232+
try {
233+
const response = await fetch(this.aluno.link_curriculo);
234+
235+
if (!response.ok) {
236+
throw new Error('Falha no download do arquivo.');
237+
}
238+
239+
const blob = await response.blob();
240+
241+
const blobUrl = window.URL.createObjectURL(blob);
242+
243+
const link = document.createElement('a');
244+
link.href = blobUrl;
245+
link.setAttribute('download', 'Curriculo.pdf');
246+
document.body.appendChild(link);
247+
link.click();
248+
249+
window.URL.revokeObjectURL(blobUrl);
250+
document.body.removeChild(link);
251+
} catch (error) {
252+
console.error('Erro ao baixar o arquivo:', error);
253+
}
254+
}
204255
},
205256
mixins: [mixinAluno],
206257
async created() {

0 commit comments

Comments
 (0)