fixes: pagination & users permissions
This commit is contained in:
@@ -10,17 +10,17 @@ export const useCompanyStore = defineStore('company', () => {
|
||||
const users = ref([]);
|
||||
const drivers = ref([]);
|
||||
const usersTotal = ref(0);
|
||||
const usersCurrentPage = ref(1);
|
||||
const usersCurrentPage = ref(0);
|
||||
const budgets = ref([]);
|
||||
const budgetsTotal = ref(0);
|
||||
const budgetsCurrentPage = ref(1);
|
||||
const budgetsCurrentPage = ref(0);
|
||||
const locations = ref([]);
|
||||
const locationsLoads = ref([]);
|
||||
const locationsTotal = ref(0);
|
||||
const locationsCurrentPage = ref(1);
|
||||
const locationsCurrentPage = ref(0);
|
||||
const proposals = ref([]);
|
||||
const proposalsTotal = ref(0);
|
||||
const proposalsCurrentPage = ref(1)
|
||||
const proposalsCurrentPage = ref(0)
|
||||
const loading = ref(false);
|
||||
|
||||
const getCompanyData = async() => {
|
||||
@@ -35,10 +35,11 @@ export const useCompanyStore = defineStore('company', () => {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
const getUsersCompany = async(limit = 10, skip = 0, reload = false) => {
|
||||
const getUsersCompany = async(limit = 1, page = 0, reload = false) => {
|
||||
const companyId = localStorage.getItem('id');
|
||||
if(users.value.length <= 0 || reload === true) {
|
||||
const filter = `company=${companyId}`;
|
||||
// const filter = `company=${companyId}`;
|
||||
const filter = `company=${companyId}&elements=${limit}&page=${page}`;
|
||||
const resp = await getUsers(filter);
|
||||
if(resp !== null && resp.total > 0) {
|
||||
usersTotal.value = resp.total;
|
||||
@@ -142,17 +143,17 @@ export const useCompanyStore = defineStore('company', () => {
|
||||
users.value = [];
|
||||
drivers.value = [];
|
||||
usersTotal.value = 0;
|
||||
usersCurrentPage.value = 1;
|
||||
usersCurrentPage.value = 0;
|
||||
budgets.value = [];
|
||||
budgetsTotal.value = 0;
|
||||
budgetsCurrentPage.value = 1;
|
||||
budgetsCurrentPage.value = 0;
|
||||
locations.value = [];
|
||||
locationsLoads.value = [];
|
||||
locationsTotal.value = 0;
|
||||
locationsCurrentPage.value = 1;
|
||||
locationsCurrentPage.value = 0;
|
||||
proposals.value = [];
|
||||
proposalsTotal.value = 0;
|
||||
proposalsCurrentPage.value = 1;
|
||||
proposalsCurrentPage.value = 0;
|
||||
// companyid = null;
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -170,7 +171,7 @@ export const useCompanyStore = defineStore('company', () => {
|
||||
const companyId = localStorage.getItem('id');
|
||||
try {
|
||||
if(proposals.value.length <= 0 || reload) {
|
||||
const endpoint = `/v1/proposals/find?carrier=${companyId}&$sort%5BcreatedAt%5D=-1&${filter}`;
|
||||
const endpoint = `/v1/proposals/find?carrier=${companyId}&${filter}&$sort%5BcreatedAt%5D=-1`;
|
||||
console.log(endpoint)
|
||||
const {data} = await api.get(endpoint);
|
||||
proposals.value = data.data;
|
||||
|
||||
@@ -8,7 +8,7 @@ export const useLoadsStore = defineStore('load', () => {
|
||||
const loads = ref([])
|
||||
const loadsDashboard = ref([]);
|
||||
const loadsTotal = ref(0)
|
||||
const loadsCurrentPage = ref(1)
|
||||
const loadsCurrentPage = ref(0)
|
||||
const proposalsOfLoads = ref([]);
|
||||
const openModalEdit = ref(false);
|
||||
const openAttachmentsModal = ref(false);
|
||||
@@ -152,7 +152,7 @@ export const useLoadsStore = defineStore('load', () => {
|
||||
loads.value = [];
|
||||
loadsDashboard.value = [];
|
||||
loadsTotal.value = 0;
|
||||
loadsCurrentPage.value = 1;
|
||||
loadsCurrentPage.value = 0;
|
||||
proposalsOfLoads.value = [];
|
||||
openModalEdit.value = false;
|
||||
openAttachmentsModal.value = false;
|
||||
|
||||
@@ -5,7 +5,7 @@ export const useVehiclesStore = defineStore('vehicles', () => {
|
||||
|
||||
const vehicles = ref([]);
|
||||
const vehiclesTotal = ref(0);
|
||||
const vehiclesCurrentPage = ref(1)
|
||||
const vehiclesCurrentPage = ref(0)
|
||||
|
||||
const fetchVehicles = async(filterQuery, reload = false) => {
|
||||
let filterArr = Object.values(filterQuery);
|
||||
@@ -17,7 +17,7 @@ export const useVehiclesStore = defineStore('vehicles', () => {
|
||||
}
|
||||
if(vehicles.value.length <= 0 || reload === true) {
|
||||
const resp = await getVehicles(filterStr + '&$sort%5BcreatedAt%5D=-1');
|
||||
console.log(resp.data);
|
||||
console.log(resp);
|
||||
if(resp !== null) {
|
||||
vehiclesTotal.value = resp.total;
|
||||
vehicles.value = resp.data;
|
||||
@@ -71,7 +71,7 @@ export const useVehiclesStore = defineStore('vehicles', () => {
|
||||
const clear = () => {
|
||||
vehicles.value = [];
|
||||
vehiclesTotal.value = 0;
|
||||
vehiclesCurrentPage.value = 1;
|
||||
vehiclesCurrentPage.value = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user