import { useState } from 'react';
import { ChevronLeft, ChevronRight, Search, Globe, Rocket } from 'lucide-react';
import type { CelestialBody } from '../types';
interface ProbeListProps {
probes: CelestialBody[];
planets: CelestialBody[];
onBodySelect: (body: CelestialBody | null) => void;
selectedBody: CelestialBody | null;
}
export function ProbeList({ probes, planets, onBodySelect, selectedBody }: ProbeListProps) {
const [isCollapsed, setIsCollapsed] = useState(false);
const [searchTerm, setSearchTerm] = useState('');
// Calculate distance for sorting
const calculateDistance = (body: CelestialBody) => {
const pos = body.positions[0];
return Math.sqrt(pos.x ** 2 + pos.y ** 2 + pos.z ** 2);
};
const processBodies = (list: CelestialBody[]) => {
return list
.filter(b =>
(b.name_zh || b.name).toLowerCase().includes(searchTerm.toLowerCase()) &&
b.type !== 'star' // Exclude Sun from list
)
.map(body => ({
body,
distance: calculateDistance(body)
}))
.sort((a, b) => a.distance - b.distance);
};
const planetList = processBodies(planets);
const probeList = processBodies(probes);
return (
{/* Main Content Panel */}
{/* Header & Search */}
{/* List Content */}
{/* Planets Group */}
{/* text-xs -> text-[10px] */}
行星 ({planetList.length})
{planetList.map(({ body, distance }) => (
onBodySelect(body)}
/>
))}
{/* Probes Group */}
{/* text-xs -> text-[10px] */}
探测器 ({probeList.length})
{probeList.map(({ body, distance }) => (
onBodySelect(body)}
/>
))}
{/* Toggle Button (Attached to the side) */}
);
}
function BodyItem({ body, distance, isSelected, onClick }: {
body: CelestialBody,
distance: number,
isSelected: boolean,
onClick: () => void
}) {
const isInactive = body.is_active === false;
return (
);
}