fix: dashboard carrier & complete register
This commit is contained in:
@@ -32,8 +32,8 @@
|
|||||||
<img src="/images/logo-eta.png" alt="Eta viaporte" width="120">
|
<img src="/images/logo-eta.png" alt="Eta viaporte" width="120">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<h2 class="my-4">COVO</h2>
|
<p class="my-4"><i class="fa-regular fa-building icon-header"></i> <span class="company-name">{{auth.user?.company?.company_name}}</span></p>
|
||||||
<p><i class="fa-solid fa-user"></i> <span class="ms-2">{{ auth.user?.first_name + ' ' + auth.user?.last_name }}</span></p>
|
<p><i class="fa-regular fa-user icon-header"></i> <span>{{ auth.user?.first_name + ' ' + auth.user?.last_name }}</span></p>
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
</div>
|
</div>
|
||||||
<ul class="list-unstyled components">
|
<ul class="list-unstyled components">
|
||||||
@@ -167,6 +167,18 @@
|
|||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon-header {
|
||||||
|
font-size: 24px;
|
||||||
|
// color: #FBBA33;
|
||||||
|
color: #FFF;
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.company-name {
|
||||||
|
font-size: 2rem;
|
||||||
|
font-weight: 900;
|
||||||
|
}
|
||||||
|
|
||||||
.logo {
|
.logo {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ export const renewToken = async() => {
|
|||||||
try {
|
try {
|
||||||
const endpoint = `/v1/account/authorize/${session}`;
|
const endpoint = `/v1/account/authorize/${session}`;
|
||||||
const {data} = await apiPublic.get(endpoint);
|
const {data} = await apiPublic.get(endpoint);
|
||||||
console.log(data);
|
|
||||||
if(data.accessToken !== null){
|
if(data.accessToken !== null){
|
||||||
return {
|
return {
|
||||||
msg: 'success',
|
msg: 'success',
|
||||||
|
|||||||
@@ -34,9 +34,10 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
user.value = resp.data.user;
|
user.value = resp.data.user;
|
||||||
sesion.value = resp.data.session_token;
|
sesion.value = resp.data.session_token;
|
||||||
token.value = resp.data.accessToken;
|
token.value = resp.data.accessToken;
|
||||||
|
console.log(resp.data.user)
|
||||||
localStorage.setItem('session', resp.data.session_token);
|
localStorage.setItem('session', resp.data.session_token);
|
||||||
localStorage.setItem('access', resp.data.accessToken);
|
localStorage.setItem('access', resp.data.accessToken);
|
||||||
localStorage.setItem('id', resp.data.user.company);
|
localStorage.setItem('id', resp.data.user.company._id);
|
||||||
checking.value = false;
|
checking.value = false;
|
||||||
} else {
|
} else {
|
||||||
noty.show = true;
|
noty.show = true;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export const useCompanyStore = defineStore('company', () => {
|
|||||||
|
|
||||||
const getUsersCompany = async(limit = 1, page = 0, reload = false) => {
|
const getUsersCompany = async(limit = 1, page = 0, reload = false) => {
|
||||||
const companyId = localStorage.getItem('id');
|
const companyId = localStorage.getItem('id');
|
||||||
|
console.log(companyId);
|
||||||
if(users.value.length <= 0 || reload === true) {
|
if(users.value.length <= 0 || reload === true) {
|
||||||
// const filter = `company=${companyId}`;
|
// const filter = `company=${companyId}`;
|
||||||
const filter = `company=${companyId}&elements=${limit}&page=${page}`;
|
const filter = `company=${companyId}&elements=${limit}&page=${page}`;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const useLoadsStore = defineStore('load', () => {
|
|||||||
const companyid = localStorage.getItem('id');
|
const companyid = localStorage.getItem('id');
|
||||||
if(loadsDashboard.value.length <= 0 || reload) {
|
if(loadsDashboard.value.length <= 0 || reload) {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/v1/loads/find`;
|
const endpoint = `/v1/loads/find?elements=100`;
|
||||||
const {data} = await api.get(endpoint);
|
const {data} = await api.get(endpoint);
|
||||||
loadsDashboard.value = data.data;
|
loadsDashboard.value = data.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -32,8 +32,9 @@ export const useLoadsStore = defineStore('load', () => {
|
|||||||
const companyId = localStorage.getItem('id');
|
const companyId = localStorage.getItem('id');
|
||||||
try {
|
try {
|
||||||
if(loadsDashboard.value.length <= 0 || reload) {
|
if(loadsDashboard.value.length <= 0 || reload) {
|
||||||
const endpoint = `/v1/proposals/find?carrier=${companyId}`;
|
const endpoint = `/v1/proposals/find?carrier=${companyId}&elements=100`;
|
||||||
const {data} = await api.get(endpoint);
|
const {data} = await api.get(endpoint);
|
||||||
|
console.log(data);
|
||||||
loadsDashboard.value = data.data.map( (e) => e.load);
|
loadsDashboard.value = data.data.map( (e) => e.load);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -122,6 +122,8 @@ import Spiner from '../components/ui/Spiner.vue';
|
|||||||
///////////////////////////
|
///////////////////////////
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Falta el populate en la respuesta para completar el registro y luego de recargar la pagina
|
||||||
|
|
||||||
const handleBack = (val) => {
|
const handleBack = (val) => {
|
||||||
step.value = val;
|
step.value = val;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import { useLoadsStore } from '../stores/loads';
|
import { useLoadsStore } from '../stores/loads';
|
||||||
import { onMounted, ref, watch } from 'vue';
|
import { onMounted, ref, watch } from 'vue';
|
||||||
import Spiner from '../components/ui/Spiner.vue';
|
import Spiner from '../components/ui/Spiner.vue';
|
||||||
|
import CardEmpty from '../components/CardEmpty.vue';
|
||||||
import { useAuthStore } from '../stores/auth';
|
import { useAuthStore } from '../stores/auth';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
|
|
||||||
@@ -33,7 +34,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const getData = async() => {
|
const getData = async() => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
if(user.value?.permissions === "role_carrier") {
|
if(user.value?.permissions === "role_carrier") {
|
||||||
@@ -52,10 +52,15 @@
|
|||||||
if(e?.load_status) {
|
if(e?.load_status) {
|
||||||
loadsData.value.push(e.load_status);
|
loadsData.value.push(e.load_status);
|
||||||
}
|
}
|
||||||
if( (user.value?.permissions === "role_shipper") && e?.categories) {
|
if( e?.categories) {
|
||||||
segmentsData.value.push(e?.categories[0].name)
|
segmentsData.value.push(e?.categories[0].name)
|
||||||
}
|
}
|
||||||
if( (user.value?.permissions === "role_shipper" ) && e?.origin?.city) {
|
|
||||||
|
// if( (user.value?.permissions === "role_carrier") && e?.load?.categories) {
|
||||||
|
// segmentsData.value.push(e?.load?.categories[0].name)
|
||||||
|
// }
|
||||||
|
|
||||||
|
if( e?.origin?.city) {
|
||||||
cities.value.push(e?.origin.city)
|
cities.value.push(e?.origin.city)
|
||||||
}
|
}
|
||||||
if(e?.origin?.state){
|
if(e?.origin?.state){
|
||||||
@@ -70,10 +75,8 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<h1 class="title my-4">Dashboard Administrativo</h1>
|
<h1 class="title my-4">Dashboard Administrativo</h1>
|
||||||
<div class="container-dashboard">
|
<div class="container-dashboard" v-if="nOfLoads > 0">
|
||||||
<div class="card-fixed"
|
<div class="card-fixed card-dashboard">
|
||||||
:class="[ ( user?.permissions === 'role_shipper') ? 'card-dashboard' : 'card-dashboard-carrier' ]"
|
|
||||||
>
|
|
||||||
<h3>Total de cargas este mes</h3>
|
<h3>Total de cargas este mes</h3>
|
||||||
<div class="main-info">
|
<div class="main-info">
|
||||||
{{ nOfLoads }}
|
{{ nOfLoads }}
|
||||||
@@ -85,9 +88,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <ChartLoad/> -->
|
<!-- <ChartLoad/> -->
|
||||||
<div class="card-fixed"
|
<div class="card-fixed card-dashboard">
|
||||||
:class="[ ( user?.permissions === 'role_shipper') ? 'card-dashboard' : 'card-dashboard-carrier']"
|
|
||||||
>
|
|
||||||
<h3>Cargas activas</h3>
|
<h3>Cargas activas</h3>
|
||||||
<div class="card-chart">
|
<div class="card-chart">
|
||||||
<Spiner v-if="loading"/>
|
<Spiner v-if="loading"/>
|
||||||
@@ -100,9 +101,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-fixed"
|
<div class="card-fixed card-dashboard">
|
||||||
:class="[ (user?.permissions === 'role_shipper') ? 'card-dashboard' : 'card-dashboard-carrier']"
|
|
||||||
v-if="user?.permissions?.includes('role_shipper')">
|
|
||||||
<h3>Segmentos más usados</h3>
|
<h3>Segmentos más usados</h3>
|
||||||
<div class="card-chart">
|
<div class="card-chart">
|
||||||
<Spiner v-if="loading"/>
|
<Spiner v-if="loading"/>
|
||||||
@@ -114,11 +113,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- </div>
|
<div class="card-fixed card-dashboard">
|
||||||
<div class="container-dashboard"> -->
|
|
||||||
<div class="card-fixed"
|
|
||||||
:class="[ (user?.permissions === 'role_shipper') ? 'card-dashboard' : 'card-dashboard-carrier']"
|
|
||||||
>
|
|
||||||
<h3>Estados más usados</h3>
|
<h3>Estados más usados</h3>
|
||||||
<div class="card-chart">
|
<div class="card-chart">
|
||||||
<Spiner v-if="loading"/>
|
<Spiner v-if="loading"/>
|
||||||
@@ -129,9 +124,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-fixed"
|
<div class="card-fixed card-dashboard">
|
||||||
:class="[ (user?.permissions === 'role_shipper') ? 'card-dashboard' : 'card-dashboard-carrier']"
|
|
||||||
v-if="user?.permissions === 'role_shipper'">
|
|
||||||
<h3>Ciudades más usadas</h3>
|
<h3>Ciudades más usadas</h3>
|
||||||
<div class="card-chart">
|
<div class="card-chart">
|
||||||
<Spiner v-if="loading"/>
|
<Spiner v-if="loading"/>
|
||||||
@@ -142,9 +135,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-fixed"
|
<div class="card-fixed card-dashboard">
|
||||||
:class="[ (user?.permissions === 'role_shipper') ? 'card-dashboard' : 'card-dashboard-carrier']"
|
|
||||||
>
|
|
||||||
<h3>Tipo de transporte más usados</h3>
|
<h3>Tipo de transporte más usados</h3>
|
||||||
<div class="card-chart">
|
<div class="card-chart">
|
||||||
<Spiner v-if="loading"/>
|
<Spiner v-if="loading"/>
|
||||||
@@ -156,6 +147,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<CardEmpty text="No hay suficientes datos para generar un analisis de cargas"/>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@@ -179,7 +173,7 @@
|
|||||||
.card-dashboard-carrier {
|
.card-dashboard-carrier {
|
||||||
width: 48%;
|
width: 48%;
|
||||||
min-height: 300px;
|
min-height: 300px;
|
||||||
max-height: 500px;
|
/* max-height: 500px; */
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,7 @@
|
|||||||
if( resp.data.user.company ) { // Registro completo
|
if( resp.data.user.company ) { // Registro completo
|
||||||
localStorage.setItem('session', resp.data.session_token);
|
localStorage.setItem('session', resp.data.session_token);
|
||||||
localStorage.setItem('access', resp.data.accessToken);
|
localStorage.setItem('access', resp.data.accessToken);
|
||||||
localStorage.setItem('id', resp.data.user.company);
|
localStorage.setItem('id', resp.data.user.company._id);
|
||||||
console.log('id', resp.data.user.company)
|
|
||||||
router.push({name: 'home'});
|
router.push({name: 'home'});
|
||||||
auth.$patch({
|
auth.$patch({
|
||||||
sesion: resp.data.session_token,
|
sesion: resp.data.session_token,
|
||||||
|
|||||||
@@ -7,9 +7,11 @@
|
|||||||
import Spiner from '../components/ui/Spiner.vue';
|
import Spiner from '../components/ui/Spiner.vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { useNotificationsStore } from '../stores/notifications';
|
import { useNotificationsStore } from '../stores/notifications';
|
||||||
|
import { useAuthStore } from '../stores/auth';
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const notifications = useNotificationsStore()
|
const notifications = useNotificationsStore()
|
||||||
|
const auth = useAuthStore();
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
email: '',
|
email: '',
|
||||||
@@ -84,11 +86,16 @@
|
|||||||
});
|
});
|
||||||
clearMessages();
|
clearMessages();
|
||||||
notifications.$patch({
|
notifications.$patch({
|
||||||
text : 'Registro exitoso, Inicie sesión!',
|
text : 'Registro exitoso, Complete su registro!',
|
||||||
show : true,
|
show : true,
|
||||||
error: false
|
error: false
|
||||||
});
|
});
|
||||||
router.push({name: 'login'});
|
auth.$patch({
|
||||||
|
sesion: result.data.session_token,
|
||||||
|
token: result.data.accessToken,
|
||||||
|
user: result.data.user,
|
||||||
|
})
|
||||||
|
router.push({name: 'register-company'});
|
||||||
} else {
|
} else {
|
||||||
msgError.value = result.msg;
|
msgError.value = result.msg;
|
||||||
clearMessages()
|
clearMessages()
|
||||||
|
|||||||
Reference in New Issue
Block a user