diff --git a/frontend/src/components/POIManager.tsx b/frontend/src/components/POIManager.tsx index 58cdbca..bfeae46 100644 --- a/frontend/src/components/POIManager.tsx +++ b/frontend/src/components/POIManager.tsx @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react'; -import { MapPin, Plus, Trash2, Calculator, Loader2 } from 'lucide-react'; +import { MapPin, Plus, Trash2, Calculator, Loader2, Crosshair } from 'lucide-react'; import { Button } from './ui/button'; import { Input } from './ui/input'; import type { AuthUser } from '@/auth/types'; @@ -10,9 +10,11 @@ interface POIManagerProps { user: AuthUser; listingType: 'RENT' | 'BUY'; onTaskCreated?: (taskId: string) => void; + pickedLocation?: { lat: number; lng: number } | null; + onStartPicking?: () => void; } -export function POIManager({ user, listingType, onTaskCreated }: POIManagerProps) { +export function POIManager({ user, listingType, onTaskCreated, pickedLocation, onStartPicking }: POIManagerProps) { const [pois, setPois] = useState([]); const [isAdding, setIsAdding] = useState(false); const [name, setName] = useState(''); @@ -26,6 +28,14 @@ export function POIManager({ user, listingType, onTaskCreated }: POIManagerProps fetchUserPOIs(user).then(setPois).catch(() => {}); }, [user]); + // When a location is picked from the map, populate lat/lng + useEffect(() => { + if (pickedLocation) { + setLat(String(pickedLocation.lat)); + setLng(String(pickedLocation.lng)); + } + }, [pickedLocation]); + const handleCreate = async () => { if (!name || !lat || !lng) return; try { @@ -41,6 +51,16 @@ export function POIManager({ user, listingType, onTaskCreated }: POIManagerProps setAddress(''); setLat(''); setLng(''); + // Auto-trigger WALK + BICYCLE distance calculation (cheap OSRM). + // TRANSIT (expensive OTP) is excluded — user triggers manually. + try { + const result = await triggerPOICalculation( + user, poi.id, ['WALK', 'BICYCLE'], listingType + ); + onTaskCreated?.(result.task_id); + } catch { + // Non-fatal: POI created successfully, calculation can be retried manually. + } } catch { // silently fail } @@ -83,6 +103,7 @@ export function POIManager({ user, listingType, onTaskCreated }: POIManagerProps + + ) : ( + + )}
- @@ -175,6 +206,7 @@ export function POIManager({ user, listingType, onTaskCreated }: POIManagerProps