diff --git a/frontend/src/components/SearchDialog.tsx b/frontend/src/components/SearchDialog.tsx index 2684699..58685cd 100644 --- a/frontend/src/components/SearchDialog.tsx +++ b/frontend/src/components/SearchDialog.tsx @@ -3,7 +3,8 @@ import { useNavigate } from 'react-router-dom'; import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; import { AhoCorasick } from '@/lib/aho'; -import { ListSystemsWithRegions } from 'wailsjs/go/main/App'; +import { ListSystemsWithRegions, SetDestinationForAll, ListCharacters, StartESILogin } from 'wailsjs/go/main/App'; +import { toast } from '@/hooks/use-toast'; interface SearchResult { system: string; @@ -80,6 +81,39 @@ export const SearchDialog: React.FC = () => { navigate(`/regions/${encodeURIComponent(r.region)}?focus=${encodeURIComponent(r.system)}`); }; + const ensureAnyLoggedIn = async (): Promise => { + 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 handleResultClick = async (e: React.MouseEvent, r: SearchResult) => { + if (e.shiftKey) { + e.preventDefault(); + e.stopPropagation(); + try { + if (!(await ensureAnyLoggedIn())) return; + await SetDestinationForAll(r.system, true, false); + toast({ title: 'Destination set', description: r.system }); + } catch (err: any) { + toast({ title: 'Failed to set destination', description: String(err), variant: 'destructive' }); + } finally { + setOpen(false); + setQuery(''); + } + return; + } + onSelect(r); + }; + return ( @@ -102,7 +136,8 @@ export const SearchDialog: React.FC = () => {