fix: issues ux

This commit is contained in:
Alexandro Uc Santos
2024-03-02 18:34:14 -06:00
parent 1ab389605d
commit 6a54ed3dbe
14 changed files with 252 additions and 55 deletions

View File

@@ -5,6 +5,7 @@ import { renewToken } from '../services/auth';
import {useNotificationsStore} from './notifications';
import {useCompanyStore} from './company';
import { useLoadsStore } from "./loads";
import { useVehiclesStore } from "./vehicles";
export const useAuthStore = defineStore('auth', () => {
@@ -12,6 +13,7 @@ export const useAuthStore = defineStore('auth', () => {
const noty = useNotificationsStore();
const company = useCompanyStore();
const loadStore = useLoadsStore();
const vehiclesStore = useVehiclesStore();
const sesion = ref('')
const checking = ref(false);
const authStatus = ref('checking');
@@ -54,16 +56,20 @@ export const useAuthStore = defineStore('auth', () => {
});
const logout = () => {
console.log('logoo....');
sesion.value = '';
token.value = '';
company.clear();
localStorage.clear();
user.value = null;
console.log(company.company);
localStorage.removeItem('access');
localStorage.removeItem('id');
localStorage.removeItem('session');
sesion.value = '';
token.value = '';
user.value = null;
checking.value = false;
authStatus.value = 'checking'
company.clear();
loadStore.clear();
vehiclesStore.clear();
router.push({name: 'login'});
}

View File

@@ -139,15 +139,19 @@ export const useCompanyStore = defineStore('company', () => {
const clear = () => { //Cuando se cierra la sesion
company.value = null;
users.value = [];
drivers.value = [];
usersTotal.value = 0;
usersCurrentPage.value = 1;
drivers.value = [];
budgets.value = [];
proposals.value = [];
budgetsTotal.value = 0;
budgetsCurrentPage.value = 1;
locations.value = [];
locationsLoads.value = [];
locationsTotal.value = 0;
locationsCurrentPage.value = 1;
proposals.value = [];
proposalsTotal.value = 0;
proposalsCurrentPage.value = 1;
// companyid = null;
loading.value = false;
}

View File

@@ -6,6 +6,7 @@ export const useLoadsStore = defineStore('load', () => {
const currentLoad = ref(null);
const loads = ref([])
const loadsDashboard = ref([]);
const loadsTotal = ref(0)
const loadsCurrentPage = ref(1)
const proposalsOfLoads = ref([]);
@@ -13,6 +14,32 @@ export const useLoadsStore = defineStore('load', () => {
const openAttachmentsModal = ref(false);
const openProposalsModal = ref(false);
const getLoadsAll = async(reload = false) => {
const companyid = localStorage.getItem('id');
if(loadsDashboard.value.length <= 0 || reload) {
try {
const endpoint = `/loads?company=${companyid}`;
const {data} = await api.get(endpoint);
loadsDashboard.value = data.data;
} catch (error) {
loadsDashboard.value = [];
console.log(error);
}
}
}
const getProposalCompanyAll = async(reload = false) => {
const companyId = localStorage.getItem('id');
try {
if(loadsDashboard.value.length <= 0 || reload) {
const endpoint = `/proposals?carrier=${companyId}`;
const {data} = await api.get(endpoint);
loadsDashboard.value = data.data.map( (e) => e.load);
}
} catch (error) {
loadsDashboard.value = [];
}
}
const getCompanyLoads = async(filterQuery, reload = false) => {
const companyid = localStorage.getItem('id');
@@ -123,6 +150,9 @@ export const useLoadsStore = defineStore('load', () => {
const clear = () => {
currentLoad.value = null;
loads.value = [];
loadsDashboard.value = [];
loadsTotal.value = 0;
loadsCurrentPage.value = 1;
proposalsOfLoads.value = [];
openModalEdit.value = false;
openAttachmentsModal.value = false;
@@ -137,6 +167,9 @@ export const useLoadsStore = defineStore('load', () => {
openAttachmentsModal,
getProposalsOfLoads,
getCompanyLoads,
getLoadsAll,
getProposalCompanyAll,
loadsDashboard,
deleteLoad,
getLoad,
saveLoad,

View File

@@ -68,6 +68,11 @@ export const useVehiclesStore = defineStore('vehicles', () => {
}
}
const clear = () => {
vehicles.value = [];
vehiclesTotal.value = 0;
vehiclesCurrentPage.value = 1;
}
return {
@@ -77,6 +82,7 @@ export const useVehiclesStore = defineStore('vehicles', () => {
fetchVehicles,
createVehicleCompany,
updateVehicleCompany,
deleteVehicleCompany
deleteVehicleCompany,
clear
}
});