import React from "react"; import "./CraftModal.css"; import { getServerUrl } from "../../../../config/api"; const CraftModal = ({ recipe, onClose, onStartCraft, activeCraft, getOwnedAmount, }) => { if (!recipe) return null; const CONNECT_URL = getServerUrl(); const ASSET_BASE_URL = `${CONNECT_URL}/static/`; const getFullTextureUrl = (path) => { if (!path) return "/assets/no-image.png"; return path.startsWith("http") ? path : `${ASSET_BASE_URL}${path}`; }; const isBusy = !!activeCraft; const outputQty = Object.values(recipe.output || {})[0] || 1; const canAfford = recipe.ingredients?.every( (ing) => getOwnedAmount(ing.itemId) >= ing.quantity, ); return (
e.stopPropagation()}> {/* Header: Icon + Title */}
{recipe.displayName}
x{outputQty}
PROTOTYPE_UNIT

{recipe.displayName}

{/* Description */}

{recipe.description || "Advanced composite material for high-tier construction."}

{/* Resources */}
Required Materials
{recipe.ingredients?.map((ing) => { const owned = getOwnedAmount(ing.itemId); const hasEnough = owned >= ing.quantity; return (
{ing.displayName} {owned} / {ing.quantity}
); })}
{/* Outcome Info */}
Production Time: {recipe.time_seconds}s
{/* Action Button */}
{activeCraft && activeCraft.recipeId === recipe.id ? (
Constructing... {activeCraft.timeLeft}s
) : ( )}
); }; export default CraftModal;