feat(app): add waypoint functionality to map and context menu
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import { useState, useRef } from 'react';
|
||||
import { System } from '@/lib/types';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { StartESILogin, ListCharacters, SetDestinationForAll } from 'wailsjs/go/main/App';
|
||||
|
||||
interface SystemContextMenuProps {
|
||||
x: number;
|
||||
@@ -10,10 +8,11 @@ interface SystemContextMenuProps {
|
||||
onRename: (newName: string) => void;
|
||||
onDelete: (system: System) => void;
|
||||
onClearConnections: (system: System) => void;
|
||||
onSetDestination: (systemName: string, viaMode: boolean) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export const SystemContextMenu = ({ x, y, system, onRename, onDelete, onClearConnections, onClose }: SystemContextMenuProps) => {
|
||||
export const SystemContextMenu = ({ x, y, system, onRename, onDelete, onClearConnections, onSetDestination, onClose }: SystemContextMenuProps) => {
|
||||
if (!system) {
|
||||
return null;
|
||||
}
|
||||
@@ -29,31 +28,6 @@ export const SystemContextMenu = ({ x, y, system, onRename, onDelete, onClearCon
|
||||
setIsRenaming(false);
|
||||
};
|
||||
|
||||
const ensureLoggedInAny = async () => {
|
||||
try {
|
||||
const list = await ListCharacters();
|
||||
if (Array.isArray(list) && list.length > 0) return true;
|
||||
await StartESILogin();
|
||||
toast({ title: 'EVE Login', description: 'Please complete login in your browser, then retry.' });
|
||||
return false;
|
||||
} catch {
|
||||
await StartESILogin();
|
||||
toast({ title: 'EVE Login', description: 'Please complete login in your browser, then retry.' });
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleSetDestinationAll = async () => {
|
||||
try {
|
||||
if (!(await ensureLoggedInAny())) return;
|
||||
await SetDestinationForAll(system.solarSystemName, true, false);
|
||||
toast({ title: 'Destination set', description: `${system.solarSystemName}` });
|
||||
onClose();
|
||||
} catch (e: any) {
|
||||
toast({ title: 'Failed to set destination', description: `${system.solarSystemName}: ${String(e)}`, variant: 'destructive' });
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={menuRef}
|
||||
@@ -111,8 +85,9 @@ export const SystemContextMenu = ({ x, y, system, onRename, onDelete, onClearCon
|
||||
</button>
|
||||
<div className="h-px bg-slate-700 my-1" />
|
||||
<button
|
||||
onClick={handleSetDestinationAll}
|
||||
onClick={(e) => { onSetDestination(system.solarSystemName, e.shiftKey); onClose(); }}
|
||||
className="w-full px-3 py-1 text-left text-emerald-400 hover:bg-slate-700 rounded text-sm"
|
||||
title="Shift-click to enter via mode and append waypoints"
|
||||
>
|
||||
Set destination
|
||||
</button>
|
||||
|
Reference in New Issue
Block a user