Fix web page due to recent changes in the API v1

This commit is contained in:
Josepablo Cruz Baas
2024-03-22 02:36:36 +00:00
parent cbd076e887
commit 9a27883b98
34 changed files with 264 additions and 141 deletions

View File

@@ -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,12 @@ 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');
console.log(companyId);
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 +144,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 +172,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;