fixes: Tracking load & load edit
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
import NotificationBadge from './ui/NotificationBadge.vue';
|
||||
import { validateEmail } from '../helpers/validations';
|
||||
import Swal from 'sweetalert2';
|
||||
import { useAuthStore } from '../stores/auth';
|
||||
import { useNotificationsStore } from '../stores/notifications';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
const emailForm = reactive({
|
||||
email: '',
|
||||
email2: '',
|
||||
@@ -13,6 +17,9 @@
|
||||
const loading = ref(false)
|
||||
const msgError = ref('');
|
||||
const msgSuccess = ref('');
|
||||
const auth = useAuthStore();
|
||||
const notifications = useNotificationsStore();
|
||||
const router = useRouter();
|
||||
|
||||
const hangleSave = () => {
|
||||
msgError.value = '';
|
||||
@@ -42,8 +49,27 @@
|
||||
Swal.showLoading()
|
||||
},
|
||||
});
|
||||
// const resp = await companyStore.deleteUserCompany(props.user._id)
|
||||
|
||||
const userData = {
|
||||
"email" : emailForm.email,
|
||||
};
|
||||
console.log(userData);
|
||||
loading.value = true;
|
||||
const response = await auth.updateProfile(userData)
|
||||
loading.value = false;
|
||||
if (response.msg !== 'success') {
|
||||
msgError.value = response.msg;
|
||||
clearMessages();
|
||||
} else {
|
||||
clearMessages();
|
||||
notifications.$patch({
|
||||
text : 'Correo electrónico se ha cambiando exitosamente!',
|
||||
show : true,
|
||||
error: false
|
||||
});
|
||||
auth.logout();
|
||||
router.push({name: 'login'});
|
||||
}
|
||||
Swal.close()
|
||||
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
show : true,
|
||||
error: false
|
||||
});
|
||||
auth.logout();
|
||||
router.push({name: 'login'});
|
||||
} else {
|
||||
msgError.value = result.msg;
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
formLoad.owner = auth.user?.first_name + ' ' + auth.user?.last_name;
|
||||
//origin_formatted_address
|
||||
if(loadStore.currentLoad){
|
||||
console.log(loadStore.currentLoad);
|
||||
formLoad.price = loadStore.currentLoad.actual_cost;
|
||||
formLoad.segment = loadStore.currentLoad.categories?.length <= 0 ? [] : loadStore.currentLoad.categories.map(m =>{
|
||||
return m;
|
||||
@@ -130,7 +131,7 @@
|
||||
|
||||
watch([originCoords, destinationCoords], async() => {
|
||||
if(originCoords.value && destinationCoords.value) {
|
||||
console.log('Se llama api direcciones ')
|
||||
// console.log('Se llama api direcciones ')
|
||||
polylines.value = await getDirections(originCoords.value, destinationCoords.value);
|
||||
}
|
||||
})
|
||||
@@ -160,12 +161,26 @@
|
||||
}
|
||||
|
||||
const getCoordsMap = async() => {
|
||||
if(loadStore.currentLoad.origin_formatted_address) {
|
||||
originCoords.value = await geocodeAddress(loadStore.currentLoad.origin_formatted_address);
|
||||
const destinationLat = loadStore.currentLoad.destination?.lat;
|
||||
const destinationLng = loadStore.currentLoad.destination?.lng;
|
||||
const originLat = loadStore.currentLoad.origin?.lat;
|
||||
const originLng = loadStore.currentLoad.origin?.lng;
|
||||
if(destinationLat && destinationLng) {
|
||||
destinationCoords.value = {lat: Number.parseFloat(destinationLat), lng: Number.parseFloat(destinationLng)}
|
||||
}
|
||||
if(loadStore.currentLoad.destination_formatted_address){
|
||||
destinationCoords.value = await geocodeAddress(loadStore.currentLoad.destination_formatted_address);
|
||||
if(originLat && originLng) {
|
||||
originCoords.value = {lat: Number.parseFloat(originLat), lng: Number.parseFloat(originLng)}
|
||||
}
|
||||
|
||||
if(originCoords.value && destinationCoords.value) {
|
||||
polylines.value = await getDirections(originCoords.value, destinationCoords.value);
|
||||
}
|
||||
// if(loadStore.currentLoad.origin_formatted_address) {
|
||||
// originCoords.value = await geocodeAddress(loadStore.currentLoad.origin_formatted_address);
|
||||
// }
|
||||
// if(loadStore.currentLoad.destination_formatted_address){
|
||||
// destinationCoords.value = await geocodeAddress(loadStore.currentLoad.destination_formatted_address);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -60,10 +60,16 @@ export const updateMyUserProfile = async(formData) => {
|
||||
try {
|
||||
const endpoint = `/v1/users/profile`;
|
||||
const {data} = await api.patch(endpoint, formData);
|
||||
return data;
|
||||
return {
|
||||
msg: "success",
|
||||
data: data
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return null;
|
||||
return {
|
||||
msg: error.response.data.error,
|
||||
data: null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,12 +59,12 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
|
||||
const updateProfile = async(data) => {
|
||||
const response = await updateMyUserProfile(data);
|
||||
console.log(response);
|
||||
if( response !== null) {
|
||||
user.value = response;
|
||||
// console.log(response);
|
||||
if( response.msg === 'success') {
|
||||
user.value = response.data;
|
||||
return response;
|
||||
} else {
|
||||
return null;
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,11 +107,11 @@
|
||||
"phone2" : user.phone2,
|
||||
};
|
||||
let respUser = await updateMyUserProfile( userData );
|
||||
console.log('User create: ', respUser);
|
||||
if(respUser === null) {
|
||||
auth.user = userData;
|
||||
// console.log('User create: ', respUser);
|
||||
if(respUser.msg === 'success') {
|
||||
auth.user = respUser.data;
|
||||
} else {
|
||||
auth.user = respUser;
|
||||
auth.user = userData;
|
||||
}
|
||||
/////// Datos debug ///////
|
||||
notifications.show = true;
|
||||
|
||||
@@ -57,11 +57,11 @@
|
||||
loading.value = true;
|
||||
const result = await auth.updateProfile(userData)
|
||||
loading.value = false;
|
||||
if(result === null) {
|
||||
msgError.value = 'Algo salio mal, intente más tarde';
|
||||
if(result.msg === 'success') {
|
||||
msgSuccess.value = 'Usuario actualizado';
|
||||
clearMessages();
|
||||
} else {
|
||||
msgSuccess.value = 'Usuario actualizado';
|
||||
msgError.value = 'Algo salio mal, intente más tarde';
|
||||
clearMessages();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,15 +35,17 @@
|
||||
const id = route.params['code'];
|
||||
await getLoadTracking(id)
|
||||
if(load.value !== null) {
|
||||
const addressOrigin = load.value.origin_geo?.coordinates;
|
||||
const addressDestination = load.value.destination_geo?.coordinates;
|
||||
if(addressOrigin !== null) {
|
||||
console.log(load.value)
|
||||
const addressOrigin = load.value?.origin_geo?.coordinates;
|
||||
const addressDestination = load.value?.destination_geo?.coordinates;
|
||||
if(addressOrigin && addressDestination) {
|
||||
originCoords.value = {lat: Number.parseFloat(addressOrigin[0]), lng: Number.parseFloat(addressOrigin[1])};
|
||||
destinationCoords.value = {lat: Number.parseFloat(addressDestination[0]), lng: Number.parseFloat(addressDestination[1])};
|
||||
|
||||
polylines.value = await getDirections(originCoords.value, destinationCoords.value);
|
||||
|
||||
}
|
||||
|
||||
if(addressDestination !== null) {
|
||||
destinationCoords.value = {lat: Number.parseFloat(addressDestination[0]), lng: Number.parseFloat(addressDestination[1])};
|
||||
}
|
||||
if(load.value.vehicle) {
|
||||
vehicleLastLocation.value = {
|
||||
lat: parseFloat(load.value.vehicle.last_location_lat),
|
||||
@@ -52,7 +54,6 @@
|
||||
console.log(vehicleLastLocation);
|
||||
}
|
||||
|
||||
polylines.value = await getDirections(originCoords.value, destinationCoords.value);
|
||||
|
||||
console.log(load.value.load_status);
|
||||
switch (load.value.load_status) {
|
||||
@@ -109,8 +110,8 @@
|
||||
fullscreenControl: true
|
||||
}"
|
||||
>
|
||||
<Marker :options="{position: originCoords, label: 'O', title: 'Destino'}" />
|
||||
<Marker :options="{position: destinationCoords, label: 'D', title: 'Origen'}" />
|
||||
<Marker v-if="originCoords" :options="{position: originCoords, label: 'O', title: 'Destino'}" />
|
||||
<Marker v-if="destinationCoords" :options="{position: destinationCoords, label: 'D', title: 'Origen'}" />
|
||||
<CustomMarker
|
||||
v-if="vehicleLastLocation && load.vehicle.background_tracking && isLoadActive"
|
||||
:options="{position: vehicleLastLocation}"
|
||||
|
||||
Reference in New Issue
Block a user