add: send whatsapp & fixes

This commit is contained in:
Alexandro Uc Santos
2024-10-12 16:41:34 -06:00
parent 54b9c138d1
commit 6dae5d9574
3 changed files with 28 additions and 11 deletions

View File

@@ -5,6 +5,7 @@
import { useCompanyStore } from '../stores/company'; import { useCompanyStore } from '../stores/company';
import { useAuthStore } from '../stores/auth'; import { useAuthStore } from '../stores/auth';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import {computed } from 'vue'
const props = defineProps({ const props = defineProps({
user: { user: {
@@ -19,8 +20,6 @@
}) })
console.log(props.user)
defineEmits(['set-user']) defineEmits(['set-user'])
const companyStore = useCompanyStore(); const companyStore = useCompanyStore();
@@ -67,6 +66,11 @@
}); });
} }
const message = computed(() => `Hola, soy ${authStore.user.first_name} de ${authStore.user.company.company_name} y vi tu contacto en Eta Viaporte. Estoy interesado en tu oferta de ${authStore.user.company.company_type === 'Carrier' ? 'carga' : 'transporte'}. ${authStore.user.company.company_type === 'Carrier' ? '¿Podrías darme más detalles sobre el tipo de carga, el origen y destino?' : '¿Podrías proporcionarme más detalles sobre la disponibilidad, la ruta y las tarifas?'} Por favor, contáctame cuando puedas. ¡Gracias!`)
const whatsappLink = computed(() => `https://wa.me/${props.user.phone}?text=${message.value}`)
</script> </script>
<template> <template>
@@ -76,7 +80,12 @@
<p><span>{{ t('labels.names') }}:</span> {{user.first_name}} {{user.last_name}}</p> <p><span>{{ t('labels.names') }}:</span> {{user.first_name}} {{user.last_name}}</p>
<p v-if="user.employee_id"><span class="font-weight-bold mr-1">{{ t('labels.registryNumber') }}:</span> {{user.employee_id}}</p> <p v-if="user.employee_id"><span class="font-weight-bold mr-1">{{ t('labels.registryNumber') }}:</span> {{user.employee_id}}</p>
<p><span>{{ t('labels.userRole') }}: </span>{{ getTypeUser(user.job_role, locale) }}</p> <p><span>{{ t('labels.userRole') }}: </span>{{ getTypeUser(user.job_role, locale) }}</p>
<p><span>{{ t('labels.phone1') }}: </span>{{user.phone}}</p> <p><span>{{ t('labels.phone1') }}: </span>
{{user.phone}}
<a :href="whatsappLink" target="_blank">
<i class="fab fa-whatsapp whatsapp"></i> <!-- Usando FontAwesome para el icono de WhatsApp -->
</a>
</p>
<!-- <p><span>Teléfono 2: </span>{{user.phone2}}</p> --> <!-- <p><span>Teléfono 2: </span>{{user.phone2}}</p> -->
<p><span>{{ t('labels.email') }}: </span>{{user.email}}</p> <p><span>{{ t('labels.email') }}: </span>{{user.email}}</p>
</div> </div>
@@ -126,6 +135,12 @@
font-weight: 700; font-weight: 700;
} }
.whatsapp {
font-size: 1.45rem;
align-items: center;
color: green;
}
@media (max-width: 768px) { @media (max-width: 768px) {
p { p {

View File

@@ -30,6 +30,8 @@
if(props?.vehicle?.driver) { if(props?.vehicle?.driver) {
const index = drivers.value.findIndex((d) => d._id === props.vehicle.driver?._id); const index = drivers.value.findIndex((d) => d._id === props.vehicle.driver?._id);
driverSelected.value = drivers.value[index]; driverSelected.value = drivers.value[index];
} else {
drivers.value = companyStore.drivers.filter((e) => !e.vehicle)
} }
}); });

View File

@@ -41,12 +41,12 @@
const id = route.params['code']; const id = route.params['code'];
await getLoadTracking(id) await getLoadTracking(id)
if(load.value !== null) { if(load.value !== null) {
console.log(load.value); // console.log(load.value);
const addressOrigin = load.value?.origin_geo?.coordinates; const origin = load.value?.origin;
const addressDestination = load.value?.destination_geo?.coordinates; const destination = load.value?.destination;
if(addressOrigin && addressDestination) { if(origin && destination) {
originCoords.value = {lat: Number.parseFloat(addressOrigin[0]), lng: Number.parseFloat(addressOrigin[1])}; originCoords.value = {lat: Number.parseFloat(origin.lat), lng: Number.parseFloat(origin.lng)};
destinationCoords.value = {lat: Number.parseFloat(addressDestination[0]), lng: Number.parseFloat(addressDestination[1])}; destinationCoords.value = {lat: Number.parseFloat(destination.lat), lng: Number.parseFloat(destination.lng)};
polylines.value = await getDirections(originCoords.value, destinationCoords.value); polylines.value = await getDirections(originCoords.value, destinationCoords.value);
@@ -70,7 +70,7 @@
isLoadActive.value = true; isLoadActive.value = true;
break; break;
case 'Delivered': case 'Delivered':
isLoadActive.value = true; isLoadActive.value = false;
break; break;
default: default:
@@ -121,7 +121,7 @@
<Marker v-if="destinationCoords" :options="{position: destinationCoords, label: 'D', title: 'Origen'}" /> <Marker v-if="destinationCoords" :options="{position: destinationCoords, label: 'D', title: 'Origen'}" />
<!-- v-if="vehicleLastLocation && load.vehicle.background_tracking && isLoadActive" --> <!-- v-if="vehicleLastLocation && load.vehicle.background_tracking && isLoadActive" -->
<CustomMarker <CustomMarker
v-if="vehicleLastLocation && isLoadActive" v-if="vehicleLastLocation && load.vehicle.background_tracking && isLoadActive"
:options="{position: vehicleLastLocation}" :options="{position: vehicleLastLocation}"
:clickable="false" :clickable="false"
:draggable="false" :draggable="false"