126 lines
2.6 KiB
Vue
126 lines
2.6 KiB
Vue
<template>
|
|
<div class="navsearch_container">
|
|
<NuxtLink to="/editar/perfil">Mi perfil</NuxtLink>
|
|
<NuxtLink :class="{ disabled: !coopIsValidated }" to="/editar/cooperativa"
|
|
>Productora</NuxtLink
|
|
>
|
|
<!-- <NuxtLink to="/editar/productora/crear">Crear productora</NuxtLink> -->
|
|
<NuxtLink :class="{ disabled: !coopIsValidated }" to="/editar/productos"
|
|
>Productos</NuxtLink
|
|
>
|
|
<NuxtLink
|
|
:class="{ disabled: !coopIsValidated }"
|
|
to="/editar/productos/importar"
|
|
>Importar</NuxtLink
|
|
>
|
|
<NuxtLink to="/" @click="handleLogout" >Cerrar sesión</NuxtLink>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { useAuthStore } from '@/stores/auth'
|
|
import { mapActions } from 'pinia'
|
|
export default {
|
|
setup() {
|
|
const auth = useAuthStore();
|
|
return {
|
|
auth,
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
coopIsValidated: false,
|
|
}
|
|
},
|
|
async mounted() {
|
|
await this.checkIfCoopValidated()
|
|
},
|
|
methods: {
|
|
...mapActions(useAuthStore, ['logout']),
|
|
async handleLogout() {
|
|
try {
|
|
await this.logout()
|
|
this.$router.push('/')
|
|
} catch (error) {
|
|
console.error('Error logging out:', error)
|
|
}
|
|
},
|
|
async checkIfCoopValidated() {
|
|
const config = useRuntimeConfig()
|
|
const accessToken = this.auth.access
|
|
const result = await $fetch('my_company/', {
|
|
baseURL: config.public.baseURL,
|
|
method: 'GET',
|
|
headers: {
|
|
Authorization: `Bearer ${accessToken}`
|
|
}
|
|
})
|
|
this.coopIsValidated = result.company.is_validated
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.navsearch_container {
|
|
border-bottom: 1px solid $color-consumo-base;
|
|
text-align: center;
|
|
padding: 20px 20px;
|
|
display: flex;
|
|
justify-content: center;
|
|
gap: 2rem;
|
|
|
|
a {
|
|
font-size: $m;
|
|
color: $color-primary;
|
|
text-decoration: none;
|
|
text-transform: uppercase;
|
|
}
|
|
a:focus {
|
|
font-weight: $bold;
|
|
}
|
|
|
|
@include mobile {
|
|
display: none;
|
|
}
|
|
}
|
|
.tooltip {
|
|
position: relative;
|
|
display: inline-block;
|
|
border-bottom: 1px dotted black;
|
|
}
|
|
|
|
.tooltip .tooltiptext {
|
|
visibility: hidden;
|
|
width: 120px;
|
|
background-color: #555;
|
|
color: #fff;
|
|
text-align: center;
|
|
border-radius: 6px;
|
|
padding: 5px 0;
|
|
position: absolute;
|
|
z-index: 1;
|
|
bottom: 125%;
|
|
left: 50%;
|
|
margin-left: -60px;
|
|
opacity: 0;
|
|
transition: opacity 0.3s;
|
|
}
|
|
|
|
.tooltip .tooltiptext::after {
|
|
content: '';
|
|
position: absolute;
|
|
top: 100%;
|
|
left: 50%;
|
|
margin-left: -5px;
|
|
border-width: 5px;
|
|
border-style: solid;
|
|
border-color: #555 transparent transparent transparent;
|
|
}
|
|
|
|
.tooltip:hover .tooltiptext {
|
|
visibility: visible;
|
|
opacity: 1;
|
|
}
|
|
</style>
|