Merge branch 'apiv1_migration' into 'master'
EN-94: fix: Migrate to api v1 See merge request jcruzbaasworkspace/enruta/webeta!3
This commit is contained in:
@@ -64,7 +64,7 @@
|
|||||||
<p><span>Dirección:</span> <template v-if="location.address">{{location.address}}, </template><template v-if="location.city">{{location.city}}, </template><template v-if="location.state">{{location.state}}</template></p>
|
<p><span>Dirección:</span> <template v-if="location.address">{{location.address}}, </template><template v-if="location.city">{{location.city}}, </template><template v-if="location.state">{{location.state}}</template></p>
|
||||||
<p><span>Teléfono:</span> {{location.phone}}</p>
|
<p><span>Teléfono:</span> {{location.phone}}</p>
|
||||||
<p><span>Tipos de camiones que se necesitan:</span> {{location.truck_type?.map((e) => e).join(', ')}}</p>
|
<p><span>Tipos de camiones que se necesitan:</span> {{location.truck_type?.map((e) => e).join(', ')}}</p>
|
||||||
<p><span>Segmento:</span> {{location.categories.map((e) => e.name).join(', ')}}</p>
|
<p><span>Segmento:</span> {{location.categories?.map((e) => e.name).join(', ')}}</p>
|
||||||
<p v-if="location.description"><span>Información adicional de la locación de carga:</span></p>
|
<p v-if="location.description"><span>Información adicional de la locación de carga:</span></p>
|
||||||
<div v-if="location.description" class="box-note mb-4">
|
<div v-if="location.description" class="box-note mb-4">
|
||||||
{{ location.description }}
|
{{ location.description }}
|
||||||
|
|||||||
@@ -59,12 +59,13 @@
|
|||||||
is_company: companyStore.company._id,
|
is_company: companyStore.company._id,
|
||||||
company_type: companyStore.company.company_type,
|
company_type: companyStore.company.company_type,
|
||||||
meta_data: companyStore.company.meta_data,
|
meta_data: companyStore.company.meta_data,
|
||||||
categories: company.segments,
|
categories: company.segments.map((e) => e._id),
|
||||||
company_city: company.cities.map((e) => e.city_name),
|
company_city: company.cities.map((e) => e.city_name),
|
||||||
company_state: company.states.map((e) => e.state_name),
|
company_state: company.states.map((e) => e.state_name),
|
||||||
truck_type: company.truckTypes.map((e) => e.meta_value),
|
truck_type: company.truckTypes.map((e) => e.meta_value),
|
||||||
company_description: company.description
|
company_description: company.description
|
||||||
};
|
};
|
||||||
|
console.log( companyData )
|
||||||
const result = await companyStore.editCompany(companyData);
|
const result = await companyStore.editCompany(companyData);
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
if(result === 'success') {
|
if(result === 'success') {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default function useSearchLoads() {
|
|||||||
filterStr = "?"+cleanfilterArr.join("&");
|
filterStr = "?"+cleanfilterArr.join("&");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const endpoint = `/loads/${filterStr}&$sort%5BcreatedAt%5D=-1`;
|
const endpoint = `/v1/loads/find${filterStr}&$sort%5BcreatedAt%5D=-1`;
|
||||||
const {data} = await api.get(endpoint);
|
const {data} = await api.get(endpoint);
|
||||||
console.log(data);
|
console.log(data);
|
||||||
total.value = data.total;
|
total.value = data.total;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import apiPublic from "../lib//axiosPublic";
|
import apiPublic from "../lib/axiosPublic";
|
||||||
|
import api from "../lib/axios";
|
||||||
import {messagesError} from '../helpers/validations';
|
import {messagesError} from '../helpers/validations';
|
||||||
|
|
||||||
export const login = async(body) => {
|
export const login = async(body) => {
|
||||||
@@ -57,7 +58,6 @@ export const renewToken = async() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const regiter = async(body) => {
|
export const regiter = async(body) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = "/v1/account/signup";
|
const endpoint = "/v1/account/signup";
|
||||||
@@ -137,4 +137,20 @@ export const recoveryPasswordConfirm = async(body) => {
|
|||||||
data: null
|
data: null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const complete_registry = async (body) => {
|
||||||
|
try {
|
||||||
|
const endpoint = "/v1/account/register";
|
||||||
|
const {data} = await api.post(endpoint, body);
|
||||||
|
return {
|
||||||
|
msg: 'success',
|
||||||
|
data
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
msg: error.response.data.error ?? 'Algo salio mal, intente más tarde',
|
||||||
|
data: null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -56,6 +56,17 @@ export const updateUser = async(user_id, formData) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const updateMyUserProfile = async(formData) => {
|
||||||
|
try {
|
||||||
|
const endpoint = `/v1/users/profile`;
|
||||||
|
const {data} = await api.patch(endpoint, formData);
|
||||||
|
return data;
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const deleteUser = async(user_id) => {
|
export const deleteUser = async(user_id) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/v1/users/member/${user_id}`;
|
const endpoint = `/v1/users/member/${user_id}`;
|
||||||
@@ -115,7 +126,7 @@ export const deleteBudget = async(id) => {
|
|||||||
|
|
||||||
export const getLocations = async(filter) => {
|
export const getLocations = async(filter) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/branches/${filter}&$limit=3&$sort%5BcreatedAt%5D=-1`;
|
const endpoint = `/v1/branches/find${filter}&$limit=3&$sort%5BcreatedAt%5D=-1`;
|
||||||
console.log(endpoint);
|
console.log(endpoint);
|
||||||
const {data} = await api.get(endpoint);
|
const {data} = await api.get(endpoint);
|
||||||
return data;
|
return data;
|
||||||
@@ -127,7 +138,7 @@ export const getLocations = async(filter) => {
|
|||||||
|
|
||||||
export const createLocation = async(formData) => {
|
export const createLocation = async(formData) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/branches`;
|
const endpoint = `/v1/branches/new`;
|
||||||
const {data} = await api.post(endpoint, formData);
|
const {data} = await api.post(endpoint, formData);
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -138,7 +149,7 @@ export const createLocation = async(formData) => {
|
|||||||
|
|
||||||
export const updateLocation = async(id, formData) => {
|
export const updateLocation = async(id, formData) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/branches/${id}`;
|
const endpoint = `/v1/branches/${id}`;
|
||||||
const {data} = await api.patch(endpoint, formData);
|
const {data} = await api.patch(endpoint, formData);
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -149,7 +160,7 @@ export const updateLocation = async(id, formData) => {
|
|||||||
|
|
||||||
export const deleteLocation = async(id) => {
|
export const deleteLocation = async(id) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/branches/${id}`;
|
const endpoint = `/v1/branches/${id}`;
|
||||||
const {data} = await api.delete(endpoint);
|
const {data} = await api.delete(endpoint);
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export const searchcategories = async(query) => {
|
|||||||
|
|
||||||
export const searchProducts = async(query) => {
|
export const searchProducts = async(query) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = "/products/?name[$regex]=" + query + "&name[$options]=i";
|
const endpoint = "/v1/products/find?regex=" + query;
|
||||||
const {data} = await api.get(endpoint);
|
const {data} = await api.get(endpoint);
|
||||||
return data.data;
|
return data.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import api from "../lib/axios";
|
|||||||
|
|
||||||
export const getVehicles = async(filter) => {
|
export const getVehicles = async(filter) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/vehicles/${filter}`;
|
const endpoint = `/v1/vehicles/find${filter}`;
|
||||||
const {data} = await api.get(endpoint);
|
const {data} = await api.get(endpoint);
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -14,7 +14,7 @@ export const getVehicles = async(filter) => {
|
|||||||
|
|
||||||
export const updateVehicle = async(id, formData) => {
|
export const updateVehicle = async(id, formData) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/vehicles/${id}`;
|
const endpoint = `/v1/vehicles/${id}`;
|
||||||
const {data} = await api.patch(endpoint, formData);
|
const {data} = await api.patch(endpoint, formData);
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -25,7 +25,7 @@ export const updateVehicle = async(id, formData) => {
|
|||||||
|
|
||||||
export const deleteVehicle = async(id) => {
|
export const deleteVehicle = async(id) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/vehicles/${id}`;
|
const endpoint = `/v1/vehicles/${id}`;
|
||||||
const {data} = await api.delete(endpoint);
|
const {data} = await api.delete(endpoint);
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -36,7 +36,7 @@ export const deleteVehicle = async(id) => {
|
|||||||
|
|
||||||
export const createVehicle = async(formData) => {
|
export const createVehicle = async(formData) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/vehicles/`;
|
const endpoint = `/v1/vehicles/new`;
|
||||||
const {data} = await api.post(endpoint, formData);
|
const {data} = await api.post(endpoint, formData);
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -47,7 +47,7 @@ export const createVehicle = async(formData) => {
|
|||||||
|
|
||||||
export const saveProposal = async(formData) => {
|
export const saveProposal = async(formData) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/proposals`;
|
const endpoint = `/v1/proposals/new`;
|
||||||
const {data} = await api.post(endpoint, formData);
|
const {data} = await api.post(endpoint, formData);
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -58,7 +58,7 @@ export const saveProposal = async(formData) => {
|
|||||||
|
|
||||||
export const updateProposal = async(id, formData) => {
|
export const updateProposal = async(id, formData) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/proposals/${id}`;
|
const endpoint = `/v1/proposals/${id}`;
|
||||||
const {data} = await api.patch(endpoint, formData);
|
const {data} = await api.patch(endpoint, formData);
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ export const useCompanyStore = defineStore('company', () => {
|
|||||||
const companyId = localStorage.getItem('id');
|
const companyId = localStorage.getItem('id');
|
||||||
try {
|
try {
|
||||||
if(proposals.value.length <= 0 || reload) {
|
if(proposals.value.length <= 0 || reload) {
|
||||||
const endpoint = `/proposals?carrier=${companyId}&$sort%5BcreatedAt%5D=-1&${filter}`;
|
const endpoint = `/v1/proposals/find?carrier=${companyId}&$sort%5BcreatedAt%5D=-1&${filter}`;
|
||||||
console.log(endpoint)
|
console.log(endpoint)
|
||||||
const {data} = await api.get(endpoint);
|
const {data} = await api.get(endpoint);
|
||||||
proposals.value = data.data;
|
proposals.value = data.data;
|
||||||
|
|||||||
@@ -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 = `/loads?company=${companyid}`;
|
const endpoint = `/v1/loads/find`;
|
||||||
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,7 +32,7 @@ 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 = `/proposals?carrier=${companyId}`;
|
const endpoint = `/v1/proposals/find?carrier=${companyId}`;
|
||||||
const {data} = await api.get(endpoint);
|
const {data} = await api.get(endpoint);
|
||||||
loadsDashboard.value = data.data.map( (e) => e.load);
|
loadsDashboard.value = data.data.map( (e) => e.load);
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ export const useLoadsStore = defineStore('load', () => {
|
|||||||
}
|
}
|
||||||
if(loads.value.length <= 0 || reload) {
|
if(loads.value.length <= 0 || reload) {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/loads?company=${companyid}&${filterStr}&$sort%5BcreatedAt%5D=-1`;
|
const endpoint = `/v1/loads/find?company=${companyid}&${filterStr}&$sort%5BcreatedAt%5D=-1`;
|
||||||
const {data} = await api.get(endpoint);
|
const {data} = await api.get(endpoint);
|
||||||
loads.value = data.data;
|
loads.value = data.data;
|
||||||
loadsTotal.value = data.total;
|
loadsTotal.value = data.total;
|
||||||
@@ -65,7 +65,7 @@ export const useLoadsStore = defineStore('load', () => {
|
|||||||
|
|
||||||
const getProposalsOfLoads = async(filterQuery) => {
|
const getProposalsOfLoads = async(filterQuery) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/proposals/?load=${filterQuery}`;
|
const endpoint = `/v1/proposals/find?load=${filterQuery}`;
|
||||||
const {data} = await api.get(endpoint);
|
const {data} = await api.get(endpoint);
|
||||||
// console.log(data);
|
// console.log(data);
|
||||||
proposalsOfLoads.value = data.data;
|
proposalsOfLoads.value = data.data;
|
||||||
@@ -77,7 +77,7 @@ export const useLoadsStore = defineStore('load', () => {
|
|||||||
|
|
||||||
const saveLoad = async(load) => {
|
const saveLoad = async(load) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/loads/`;
|
const endpoint = `/v1/loads/new`;
|
||||||
const {data} = await api.post(endpoint, load);
|
const {data} = await api.post(endpoint, load);
|
||||||
loadsTotal.value++;
|
loadsTotal.value++;
|
||||||
return data;
|
return data;
|
||||||
@@ -89,7 +89,7 @@ export const useLoadsStore = defineStore('load', () => {
|
|||||||
|
|
||||||
const updateProposal = async(id, proposal) => {
|
const updateProposal = async(id, proposal) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/proposals/${id}`;
|
const endpoint = `/v1/proposals/${id}`;
|
||||||
const {data} = await api.patch(endpoint, proposal);
|
const {data} = await api.patch(endpoint, proposal);
|
||||||
// console.log(data);
|
// console.log(data);
|
||||||
return data;
|
return data;
|
||||||
@@ -101,7 +101,7 @@ export const useLoadsStore = defineStore('load', () => {
|
|||||||
|
|
||||||
const deleteProposal = async(id) => {
|
const deleteProposal = async(id) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/proposals/${id}`;
|
const endpoint = `/v1/proposals/${id}`;
|
||||||
const {data} = await api.delete(endpoint);
|
const {data} = await api.delete(endpoint);
|
||||||
// console.log(data);
|
// console.log(data);
|
||||||
return data;
|
return data;
|
||||||
@@ -113,7 +113,7 @@ export const useLoadsStore = defineStore('load', () => {
|
|||||||
|
|
||||||
const updateLoad = async(loadId, load) => {
|
const updateLoad = async(loadId, load) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/loads/${loadId}`;
|
const endpoint = `/v1/loads/${loadId}`;
|
||||||
const {data} = await api.patch(endpoint, load);
|
const {data} = await api.patch(endpoint, load);
|
||||||
// console.log(data);
|
// console.log(data);
|
||||||
return data;
|
return data;
|
||||||
@@ -125,7 +125,7 @@ export const useLoadsStore = defineStore('load', () => {
|
|||||||
|
|
||||||
const deleteLoad = async(loadId) => {
|
const deleteLoad = async(loadId) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/loads/${loadId}`;
|
const endpoint = `/v1/loads/${loadId}`;
|
||||||
console.log(endpoint);
|
console.log(endpoint);
|
||||||
const {data} = await api.delete(endpoint);
|
const {data} = await api.delete(endpoint);
|
||||||
loadsTotal.value--;
|
loadsTotal.value--;
|
||||||
@@ -138,7 +138,7 @@ export const useLoadsStore = defineStore('load', () => {
|
|||||||
|
|
||||||
const getLoad = async(filterQuery) => {
|
const getLoad = async(filterQuery) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/loads/${filterQuery}`;
|
const endpoint = `/v1/loads/find/${filterQuery}`;
|
||||||
const {data} = await api.get(endpoint);
|
const {data} = await api.get(endpoint);
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
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';
|
import { useAuthStore } from '../stores/auth';
|
||||||
|
import { complete_registry } from "../services/auth";
|
||||||
|
import { updateMyUserProfile } from "../services/company"
|
||||||
|
|
||||||
const notifications = useNotificationsStore();
|
const notifications = useNotificationsStore();
|
||||||
const auth = useAuthStore();
|
const auth = useAuthStore();
|
||||||
@@ -63,14 +65,36 @@
|
|||||||
console.log(company);
|
console.log(company);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSendRegister = () => {
|
const handleSendRegister = async () => {
|
||||||
const error = validatiosUser();
|
const error = validatiosUser();
|
||||||
if(error != '') {
|
if(error != '') {
|
||||||
msgError.value = error;
|
msgError.value = error;
|
||||||
clearMessages();
|
clearMessages();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(user);
|
const companyData = {
|
||||||
|
company_name : company.name,
|
||||||
|
rfc : company.rfc,
|
||||||
|
categories: company.segments.map((e) => e._id ),
|
||||||
|
company_city: company.cities.map((e) => e.city_name),
|
||||||
|
company_state: company.states.map((e) => e.state_name),
|
||||||
|
truck_type: company.truckTypes.map((e) => e.meta_value),
|
||||||
|
company_description : company.description,
|
||||||
|
company_type : typeCompany.typeCompany,
|
||||||
|
};
|
||||||
|
const result = await complete_registry( companyData );
|
||||||
|
console.log(result);
|
||||||
|
if(result.msg === 'success' && result.data !== null){
|
||||||
|
localStorage.setItem('id', result.data._id);
|
||||||
|
}
|
||||||
|
|
||||||
|
const userData = {
|
||||||
|
"first_name" : user.name,
|
||||||
|
"last_name" : user.lastName,
|
||||||
|
"phone" : user.phone1,
|
||||||
|
"phone2" : user.phone2,
|
||||||
|
};
|
||||||
|
await updateMyUserProfile( userData );
|
||||||
/////// Datos debug ///////
|
/////// Datos debug ///////
|
||||||
notifications.show = true;
|
notifications.show = true;
|
||||||
notifications.text = 'Los datos se llenaron correctamente';
|
notifications.text = 'Los datos se llenaron correctamente';
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
const resp = await login(data);
|
const resp = await login(data);
|
||||||
if(resp.msg === 'success') {
|
if(resp.msg === 'success') {
|
||||||
console.log(resp.data.user);
|
console.log(resp.data.user);
|
||||||
if(resp.data.user.company) {
|
if( resp.data.user.company ) {
|
||||||
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);
|
||||||
@@ -50,6 +50,13 @@
|
|||||||
user: resp.data.user,
|
user: resp.data.user,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
auth.$patch({
|
||||||
|
sesion: resp.data.session_token,
|
||||||
|
token: resp.data.accessToken,
|
||||||
|
user: resp.data.user,
|
||||||
|
})
|
||||||
|
localStorage.setItem('session', resp.data.session_token);
|
||||||
|
localStorage.setItem('access', resp.data.accessToken);
|
||||||
router.push({name: 'register-company'});
|
router.push({name: 'register-company'});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user