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