"use client"; import React from "react"; import { Planet, Starship } from "@/types/swapi"; import { t } from "@/content/locales"; interface ActionPanelProps { planet?: Planet | null; enemy?: Starship | null; onAction: () => void; onEscape?: () => void; isLoading?: boolean; } const getPlanetTheme = (terrain: string = "", climate: string = "") => { const terr = terrain.toLowerCase(); const clim = climate.toLowerCase(); if (terr.includes("ocean") || terr.includes("water")) return { color: "text-blue-400", border: "border-blue-500", glow: "shadow-[0_0_20px_#3b82f6]", label: t.ACTION_PANEL.MODES.AQUATIC, }; if (terr.includes("forest") || terr.includes("jungle")) return { color: "text-green-400", border: "border-green-500", glow: "shadow-[0_0_20px_#22c55e]", label: t.ACTION_PANEL.MODES.VERDANT, }; if (terr.includes("desert") || clim.includes("arid")) return { color: "text-orange-400", border: "border-orange-500", glow: "shadow-[0_0_20px_#f97316]", label: t.ACTION_PANEL.MODES.ARID, }; if ( terr.includes("ice") || terr.includes("glacier") || clim.includes("frozen") ) return { color: "text-cyan-200", border: "border-cyan-300", glow: "shadow-[0_0_20px_#a5f3fc]", label: t.ACTION_PANEL.MODES.CRYO, }; if (terr.includes("city") || terr.includes("urban")) return { color: "text-purple-400", border: "border-purple-500", glow: "shadow-[0_0_20px_#a855f7]", label: t.ACTION_PANEL.MODES.ECUMENOPOLIS, }; return { color: "text-yellow-500", border: "border-yellow-500", glow: "shadow-[0_0_20px_#eab308]", label: t.ACTION_PANEL.MODES.STANDARD, }; }; export default function ActionPanel({ planet, enemy, onAction, onEscape, isLoading, }: ActionPanelProps) { const isCombat = !!enemy; const theme = !isCombat && planet ? getPlanetTheme(planet.terrain, planet.climate) : { color: "text-red-500", border: "border-red-600", glow: "shadow-[0_0_30px_#dc2626]", label: t.ACTION_PANEL.MODES.HOSTILE, }; const displayName = isCombat ? enemy.name : planet?.name; const displaySubtitle = isCombat ? `${t.ACTION_PANEL.LABELS.CLASS}: ${enemy.starship_class} // ${t.ACTION_PANEL.LABELS.CREW}: ${enemy.crew}` : `${t.ACTION_PANEL.LABELS.SECTOR}: ${planet?.climate} // ${planet?.terrain}`; return (
{isCombat ? (
!
) : ( <>
)}
{theme.label}

{displayName}

{displaySubtitle}

{isCombat ? t.ACTION_PANEL.LABELS.MANUFACTURER : t.ACTION_PANEL.LABELS.POPULATION}

{isCombat ? enemy.manufacturer : planet?.population.toLocaleString()}

{isCombat ? t.ACTION_PANEL.LABELS.COST : t.ACTION_PANEL.LABELS.GRAVITY}

{isCombat ? `${enemy.cost_in_credits} Cr` : planet?.gravity}

{isCombat ? t.ACTION_PANEL.STATUS.COMBAT_WARNING : t.ACTION_PANEL.STATUS.PLANET_SCAN}

{isCombat && ( )}
); }