Fix: map singleton state, schedules view sync, and carousel image error handling

This commit is contained in:
2026-02-28 22:38:59 -05:00
parent 1dd250ca42
commit 91ef07b3ed
3 changed files with 31 additions and 24 deletions

View File

@ -45,7 +45,6 @@ const unitFetchInterval = ref<any>(null);
const userCoords = ref<{ lat: number; lng: number } | null>(null);
const optimalStopPulse = ref<any>(null);
const showRouteDropdown = ref(false);
const routeCardRef = ref<HTMLElement | null>(null);
const wasSelectedFromMap = ref(false);
const isInternalSelection = ref(false);
@ -129,6 +128,13 @@ async function claimPromo() {
}
}
function handleImageError(event: Event) {
const target = event.target as HTMLImageElement;
if (target) {
target.src = getImageUrl(null, 'coupon');
}
}
onMounted(async () => {
const navbar = document.querySelector('#navbar-admin') ?? document.querySelector('nav') ?? document.querySelector('header');
if (navbar) {
@ -468,6 +474,10 @@ function locateUser(): Promise<void> {
if (userMarker.value) {
if (typeof userMarker.value.setMap === 'function') {
userMarker.value.setMap(null);
// Clear listeners for the old marker
if (typeof (window as any).google !== 'undefined' && (window as any).google.maps?.event?.clearInstanceListeners) {
(window as any).google.maps.event.clearInstanceListeners(userMarker.value);
}
}
}
@ -525,6 +535,10 @@ async function highlightOptimalStopForRoute() {
// Añadir el PULSO NARANJA
if (optimalStopPulse.value && typeof optimalStopPulse.value.setMap === 'function') {
optimalStopPulse.value.setMap(null);
// Clear listeners for the old pulse marker
if (typeof (window as any).google !== 'undefined' && (window as any).google.maps?.event?.clearInstanceListeners) {
(window as any).google.maps.event.clearInstanceListeners(optimalStopPulse.value);
}
}
optimalStopPulse.value = addHtmlMarker(
@ -548,10 +562,6 @@ async function highlightOptimalStopForRoute() {
}
}
// walking route functions removed
</script>
<template>
@ -754,7 +764,7 @@ async function highlightOptimalStopForRoute() {
<img
:src="getImageUrl(currentPromo.image_url, 'coupon')"
class="sheet-img"
@error="(e) => (e.target as HTMLImageElement).src = getImageUrl(null, 'coupon')"
@error="handleImageError"
/>
<span v-if="currentPromo.discount_percentage" class="sheet-discount">-{{ currentPromo.discount_percentage }}%</span>
</div>
@ -795,7 +805,7 @@ async function highlightOptimalStopForRoute() {
<img
:src="getImageUrl(selectedPromo.image_url, 'coupon')"
class="promo-img-modal"
@error="(e) => (e.target as HTMLImageElement).src = getImageUrl(null, 'coupon')"
@error="handleImageError"
/>
<div class="promo-badge-modal">PROMO</div>
</div>