import { PI_TYPES_MAP } from "@/const"; import { planetCalculations } from "@/planets"; import { AccessToken, PlanetWithInfo } from "@/types"; import { Card, Table, TableBody, TableCell, TableRow, Tooltip, Typography, useTheme, } from "@mui/material"; import { DateTime } from "luxon"; import Countdown from "react-countdown"; import { timeColor } from "../PlanetaryInteraction/alerts"; import Image from "next/image"; import { ColorContext, SessionContext } from "@/app/context/Context"; import { useContext } from "react"; export const PlanetConfigDialog = ({ planet, character, }: { planet: PlanetWithInfo; character: AccessToken; }) => { const theme = useTheme(); const { colors } = useContext(ColorContext); const { piPrices } = useContext(SessionContext); const { extractors, localProduction, localImports, localExports } = planetCalculations(planet); return (
{planet.infoUniverse?.name}
{planet.upgrade_level}
{extractors.map((e, idx) => { return (
{e ? ( ) : ( "STOPPED" )} { PI_TYPES_MAP[ e.extractor_details?.product_type_id ?? 0 ]?.name }
); })}
{Array.from(localProduction).map((schematic, idx) => { return ( {schematic[1].name} ); })}
{localImports.map((i) => ( {PI_TYPES_MAP[i.type_id].name} ))}
{localExports.map((exports) => ( {PI_TYPES_MAP[exports.typeId].name} ))}
{localExports.map((exports) => ( {exports.amount} ))}
{localExports.map((e) => { const valueInMillions = (((piPrices?.appraisal.items.find( (a) => a.typeID === e.typeId, )?.prices.sell.min ?? 0) * e.amount) / 1000000) * 24 * 30; const displayValue = valueInMillions >= 1000 ? `${(valueInMillions / 1000).toFixed(2)} B` : `${valueInMillions.toFixed(2)} M`; return ( {displayValue} ); })}
); };