feat(tesla): collapse OD strip when connected, sync with in-car nav destination
- Server: include active_route_destination (lat/lng/eta) from drive_state. - When Tesla is connected, the Origin → Destination strip collapses to a single ConnectedTripStrip: "From car · Where to?". The origin is implicit (the car's GPS), the manual From input + crosshair button disappear. - If Tesla nav already has a destination, it auto-fills as the trip destination; if the user has typed something else, an inline "Use Tesla nav" button offers a one-tap swap. - Mocks: driving + charging scenarios include an activeRoute so the flow is testable end-to-end via ?mockTesla=driving / ?mockTesla=charging.
This commit is contained in:
@@ -210,6 +210,21 @@ router.get('/api/tesla/state', requireOwner, async (req, res) => {
|
||||
vin: tokens.vin ? `…${tokens.vin.slice(-4)}` : null,
|
||||
vehicleName: vs.vehicle_name ?? null,
|
||||
softwareVersion: vs.car_version ?? null,
|
||||
// Active in-car nav destination (set in Tesla nav by the driver, or by
|
||||
// our own send-to-nav). Useful as a default trip destination.
|
||||
activeRoute: (typeof ds.active_route_destination === 'string' && ds.active_route_destination)
|
||||
? {
|
||||
destination: ds.active_route_destination,
|
||||
lat: typeof ds.active_route_latitude === 'number' ? ds.active_route_latitude : null,
|
||||
lng: typeof ds.active_route_longitude === 'number' ? ds.active_route_longitude : null,
|
||||
kmToArrival: typeof ds.active_route_miles_to_arrival === 'number'
|
||||
? Math.round(ds.active_route_miles_to_arrival * 1.60934) : null,
|
||||
minutesToArrival: typeof ds.active_route_minutes_to_arrival === 'number'
|
||||
? Math.round(ds.active_route_minutes_to_arrival) : null,
|
||||
trafficMinutesDelay: typeof ds.active_route_traffic_minutes_delay === 'number'
|
||||
? Math.round(ds.active_route_traffic_minutes_delay) : 0,
|
||||
}
|
||||
: null,
|
||||
fetchedAt: Date.now(),
|
||||
});
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user