Skip to content

Commit

Permalink
Add vaga page for aluno
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-Alvarenga committed Nov 4, 2024
1 parent c05ab14 commit 99d1875
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 1 deletion.
9 changes: 9 additions & 0 deletions client/src/router/routes/aluno.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
isAuthAluno,
isCompletedAluno
} from '../guards/guards.js';
import Vaga from '../../views/aluno/Vaga.vue';

export const alunoRoutes = [
{
Expand Down Expand Up @@ -117,6 +118,14 @@ export const alunoRoutes = [
(await isAuthAluno()) ? next() : next("/login");
}
},
{
path: "/aluno/vaga/:id",
name: "VagaALuno",
component: Vaga,
beforeEnter: async (to, from, next) => {
(await isAuthAluno()) ? next() : next("/login");
}
},
{
path: "/config",
name: "Config",
Expand Down
5 changes: 4 additions & 1 deletion client/src/router/routes/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ export const sharedRoutes = [
{
path: '/vaga/:id',
name: 'Vaga',
component: Vaga
component: Vaga,
beforeEnter: async (to, from, next) => {
(await isAuthAluno()) ? next(`/aluno/vaga/${to.params.id}`) : next();
}
},
{
path: '/:pathMatch(.*)*',
Expand Down
171 changes: 171 additions & 0 deletions client/src/views/aluno/Vaga.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<template>
<Header />
<div id="app">
<main>
<AsideDashboard pageName="estagios" />
<div class="content">
<div class="back-button">
<router-link to="/vagas">
<img src="../../assets/icons/angulo.png" alt="Voltar" />
Voltar
</router-link>
</div>

<div class="vaga">
<div class="vaga-header">
<h3 v-text="vaga.titulo"></h3>
<p class="status" v-text="situacao[vaga.status]"></p>
</div>

<div class="main-information">
<div class="enterprise">
<img
:src="vaga.empresa.logo"
:alt="vaga.empresa.name"
/>
<div class="info-enterprise">
<strong>Empresa:</strong>
<router-link
:to="'/empresa/' + vaga.empresa.cnpj"
>{{ vaga.empresa.name }}</router-link
>
</div>
</div>
<div class="remuneracao">
<strong>Remuneração:</strong>
<span v-text="vaga.remuneracao"></span>
</div>
</div>

<section class="vaga-info">
<h2>Requisitos</h2>
<ul class="requisitos">
<li
v-for="(requisito, index) in parsedRequisitos"
:key="index"
>
<p v-text="requisito"></p>
</li>
</ul>

<div class="vaga-details">
<p>
<strong>Carga Horária:</strong>
<span v-text="vaga.cargaHoraria"></span>
</p>
<p>
<strong>Entrada:</strong>
<span v-text="vaga.entrada"></span>
</p>
<p>
<strong>Saída:</strong>
<span v-text="vaga.saida"></span>
</p>
</div>

<section class="descricao">
<h2>Descrição</h2>
<p v-text="vaga.descricao"></p>
</section>

<h2>Benefícios</h2>
<ul class="beneficios">
<li
v-for="(beneficio, index) in parsedBeneficios"
:key="index"
>
<p v-text="beneficio"></p>
</li>
</ul>
</section>
</div>
</div>
</main>
</div>
<Footer />
</template>

<script>
import Header from "../../components/aluno/Header.vue";
import Footer from "../../components/Footer.vue";
import AsideDashboard from "../../components/aluno/AsideDashboard.vue";
import router from "../../router/index.js";
import Cookies from "js-cookie";
import { getVaga } from "../../services/api/shared";
import { getMeAluno } from "../../services/api/aluno";
export default {
name: "Vaga",
components: {
Header,
AsideDashboard,
Footer,
},
data() {
return {
vaga: {
requisitos: "[]",
beneficios: "[]",
},
aluno: {
email: "",
token: "",
},
situacao: {
DISPONIVEL: "Vaga disponível",
INDISPONIVEL: "Vaga indisponível",
},
};
},
computed: {
parsedRequisitos() {
return JSON.parse(this.vaga.requisitos);
},
parsedBeneficios() {
return JSON.parse(this.vaga.beneficios);
},
},
methods: {
async getVaga() {
try {
const response = await getVaga({ id: this.$route.params.id });
if (response.status >= 200 && response.status < 300) {
this.vaga = response.data.vaga;
} else {
console.error(
"Erro ao recuperar os dados da vaga:",
response.message,
);
}
} catch (error) {
console.error(
"Erro ao recuperar os dados da vaga:",
error.message,
);
}
},
async testAluno() {
this.aluno.token = Cookies.get("token");
if (this.aluno.token) {
const responseMail = await getMeAluno(this.aluno.token);
if (responseMail.status >= 200 && responseMail.status < 300) {
this.aluno.email = responseMail.data.email;
} else {
console.log("Erro ao buscar aluno");
}
} else {
console.log("Token de aluno não encontrado");
}
},
},
async created() {
await this.testAluno();
await this.getVaga();
},
};
</script>

<style lang="scss" scoped>
@import "../../scss/pages/shared/_vaga.scss";
</style>

0 comments on commit 99d1875

Please sign in to comment.