Add POI feature and imporve the overall backend implementation

This commit is contained in:
Urtzi Alfaro
2025-11-12 15:34:10 +01:00
parent e8096cd979
commit 5783c7ed05
173 changed files with 16862 additions and 9078 deletions

View File

@@ -71,8 +71,8 @@ export const useDemoTour = () => {
}, 500);
}, [navigate]);
const startTour = useCallback((fromStep: number = 0) => {
console.log('[useDemoTour] startTour called with fromStep:', fromStep);
const startTour = useCallback((fromStep: number = 0, retryCount: number = 0) => {
console.log('[useDemoTour] startTour called with fromStep:', fromStep, 'retry:', retryCount);
// Check if we're already on the dashboard
const currentPath = window.location.pathname;
@@ -81,7 +81,7 @@ export const useDemoTour = () => {
// Store tour intent in sessionStorage before navigation
sessionStorage.setItem('demo_tour_should_start', 'true');
sessionStorage.setItem('demo_tour_start_step', fromStep.toString());
// Navigate to dashboard
navigate(ROUTES.DASHBOARD);
return;
@@ -90,20 +90,41 @@ export const useDemoTour = () => {
const steps = isMobile ? getMobileTourSteps() : getDemoTourSteps();
console.log('[useDemoTour] Using', isMobile ? 'mobile' : 'desktop', 'steps, total:', steps.length);
// Check if first element exists (only if we're on the dashboard)
// Check if critical tour elements exist (only if we're on the dashboard)
if (currentPath === ROUTES.DASHBOARD) {
const firstElement = steps[0]?.element;
if (firstElement) {
const selector = typeof firstElement === 'string' ? firstElement : String(firstElement);
// Validate critical dashboard elements
const criticalSelectors = [
'[data-tour="demo-banner"]',
'[data-tour="dashboard-stats"]'
];
let missingElement = null;
for (const selector of criticalSelectors) {
const el = document.querySelector(selector);
console.log('[useDemoTour] First element exists:', !!el, 'selector:', selector);
if (!el) {
console.warn('[useDemoTour] First tour element not found in DOM! Delaying tour start...');
// Retry after DOM is ready
setTimeout(() => startTour(fromStep), 500);
missingElement = selector;
break;
}
}
if (missingElement) {
// Retry up to 5 times with exponential backoff
if (retryCount < 5) {
const delay = Math.min(500 * Math.pow(1.5, retryCount), 3000);
console.warn(`[useDemoTour] Critical tour element "${missingElement}" not found! Retrying in ${delay}ms (attempt ${retryCount + 1}/5)...`);
setTimeout(() => startTour(fromStep, retryCount + 1), delay);
return;
} else {
console.error(`[useDemoTour] Failed to find critical element "${missingElement}" after 5 retries. Tour cannot start.`);
// Clear the tour start flag to prevent infinite retry loops
sessionStorage.removeItem('demo_tour_should_start');
sessionStorage.removeItem('demo_tour_start_step');
clearTourStartPending();
return;
}
}
console.log('[useDemoTour] All critical tour elements found, starting tour...');
}
const config = getDriverConfig(handleStepComplete);