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