diff --git a/frontend/src/components/MapNode.tsx b/frontend/src/components/MapNode.tsx index 0492a3b..052e465 100644 --- a/frontend/src/components/MapNode.tsx +++ b/frontend/src/components/MapNode.tsx @@ -15,6 +15,7 @@ interface MapNodeProps { security?: number; signatures?: number; isDraggable?: boolean; + disableNavigate?: boolean; } export const MapNode: React.FC = ({ @@ -30,7 +31,8 @@ export const MapNode: React.FC = ({ type, security, signatures, - isDraggable = false + isDraggable = false, + disableNavigate = false, }) => { const [isHovered, setIsHovered] = useState(false); const [isDragging, setIsDragging] = useState(false); @@ -142,7 +144,7 @@ export const MapNode: React.FC = ({ onMouseDown={handleMouseDown} onClick={(e) => { e.stopPropagation(); - onClick(); + if (!disableNavigate) onClick(); }} onDoubleClick={(e) => { e.stopPropagation(); diff --git a/frontend/src/components/RegionMap.tsx b/frontend/src/components/RegionMap.tsx index 7b3c4ee..e1a94f4 100644 --- a/frontend/src/components/RegionMap.tsx +++ b/frontend/src/components/RegionMap.tsx @@ -9,6 +9,7 @@ import { System, Position, Connection as ConnectionType } from '@/lib/types'; import { getSecurityColor } from '@/utils/securityColors'; import { Header } from './Header'; import { ListCharacters, StartESILogin, SetDestinationForAll, AddWaypointForAllByName } from 'wailsjs/go/main/App'; +import { toast } from '@/hooks/use-toast'; interface RegionMapProps { regionName: string; @@ -104,7 +105,32 @@ export const RegionMap = ({ regionName, focusSystem, isCompact = false, isWormho } }, [isWormholeRegion]); - const handleSystemClick = (systemName: string) => { + const ensureAnyLoggedIn = async () => { + try { + const list = await ListCharacters(); + if (Array.isArray(list) && list.length > 0) return true; + await StartESILogin(); + toast({ title: 'EVE Login', description: 'Complete login in your browser, then retry.' }); + return false; + } catch (e: any) { + await StartESILogin(); + toast({ title: 'EVE Login', description: 'Complete login in your browser, then retry.', variant: 'destructive' }); + return false; + } + }; + + const handleSystemClick = async (systemName: string) => { + if (viaMode) { + try { + if (!(await ensureAnyLoggedIn())) return; + await AddWaypointForAllByName(systemName, false); + toast({ title: 'Waypoint added', description: systemName }); + } catch (e: any) { + console.error('Append waypoint failed:', e); + toast({ title: 'Failed to add waypoint', description: String(e), variant: 'destructive' }); + } + return; + } if (focusSystem === systemName) return; navigate(`/regions/${regionName}/${systemName}`); }; @@ -374,31 +400,20 @@ export const RegionMap = ({ regionName, focusSystem, isCompact = false, isWormho } }; - const ensureAnyLoggedIn = async () => { - try { - const list = await ListCharacters(); - if (Array.isArray(list) && list.length > 0) return true; - await StartESILogin(); - return false; - } catch { - await StartESILogin(); - return false; - } - }; - const onSetDestination = async (systemName: string, wantVia: boolean) => { try { if (!(await ensureAnyLoggedIn())) return; if (!viaMode) { - // First selection: set destination and optionally enter via mode await SetDestinationForAll(systemName, true, false); + toast({ title: 'Destination set', description: systemName }); if (wantVia) setViaMode(true); } else { - // Append waypoint await AddWaypointForAllByName(systemName, false); + toast({ title: 'Waypoint added', description: systemName }); } - } catch (e) { + } catch (e: any) { console.error('Set destination failed:', e); + toast({ title: 'Failed to set destination', description: String(e), variant: 'destructive' }); } }; @@ -442,7 +457,7 @@ export const RegionMap = ({ regionName, focusSystem, isCompact = false, isWormho width="100%" height="100%" viewBox={`${viewBox.x} ${viewBox.y} ${viewBox.width} ${viewBox.height}`} - className={`cursor-grab active:cursor-grabbing ${viaMode ? 'ring-2 ring-emerald-500' : ''}`} + className="cursor-grab active:cursor-grabbing" onMouseDown={handleMouseDown} onMouseMove={(e) => { if (isPanning) { @@ -508,6 +523,7 @@ export const RegionMap = ({ regionName, focusSystem, isCompact = false, isWormho security={system.security} signatures={system.signatures} isDraggable={isWormholeRegion} + disableNavigate={viaMode} /> ))} @@ -536,6 +552,12 @@ export const RegionMap = ({ regionName, focusSystem, isCompact = false, isWormho )} + {viaMode && ( +
+ VIA mode (Esc to exit) +
+ )} + {/* Context Menu */} {contextMenu && ( void; onDelete: (system: System) => void; onClearConnections: (system: System) => void; - onSetDestination: (systemName: string, viaMode: boolean) => void; + onSetDestination?: (systemName: string, viaMode: boolean) => void; onClose: () => void; } @@ -28,6 +28,16 @@ export const SystemContextMenu = ({ x, y, system, onRename, onDelete, onClearCon setIsRenaming(false); }; + const handleSetDestinationClick = (e: React.MouseEvent) => { + const via = !!e.shiftKey; + if (typeof onSetDestination === 'function') { + onSetDestination(system.solarSystemName, via); + } else { + console.error('onSetDestination not provided'); + } + onClose(); + }; + return (