/** * Investment Page - STC Theme (Gold/Black) */ import { FC, useState } from 'react'; import { useAgents, useAllocations, useInvestmentSummary } from '../hooks/useInvestment'; import { AgentCard, AllocationCard, AllocationModal } from '../components'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Skeleton } from '@/components/ui/skeleton'; import type { AgentConfig, AllocationWithAgent, AgentType } from '../types'; export const InvestmentPage: FC = () => { const [showModal, setShowModal] = useState(false); const [selectedAgent, setSelectedAgent] = useState(null); const [selectedAllocation, setSelectedAllocation] = useState(null); const { data: agents, isLoading: agentsLoading } = useAgents(); const { data: allocations, isLoading: allocationsLoading } = useAllocations(); const { data: summary } = useInvestmentSummary(); const handleAllocate = (agentType: AgentType) => { const agent = agents?.find((a) => a.agentType === agentType); const existingAllocation = allocations?.find( (a) => a.agentType === agentType && a.status === 'active' ); setSelectedAgent(agent || null); setSelectedAllocation(existingAllocation || null); setShowModal(true); }; const handleManageAllocation = (allocation: AllocationWithAgent) => { const agent = agents?.find((a) => a.agentType === allocation.agentType); setSelectedAgent(agent || null); setSelectedAllocation(allocation); setShowModal(true); }; const handleCloseModal = () => { setShowModal(false); setSelectedAgent(null); setSelectedAllocation(null); }; // Get allocation value by agent type const getAllocationValue = (agentType: AgentType) => { const allocation = allocations?.find( (a) => a.agentType === agentType && a.status === 'active' ); return allocation?.currentValue || 0; }; if (agentsLoading || allocationsLoading) { return (
{[1, 2, 3].map((i) => ( ))}
); } const activeAllocations = allocations?.filter((a) => a.status === 'active') || []; return (
{/* Header */}

Investment Agents

Allocate funds to AI-powered trading agents

{/* Portfolio Summary */} {summary && (summary.totalAllocated > 0 || activeAllocations.length > 0) && (

Your Portfolio

Total Allocated

${summary.totalAllocated.toLocaleString()}

Current Value

${summary.currentValue.toLocaleString()}

Total P&L

= 0 ? 'text-green-400' : 'text-red-400'}`}> {summary.totalPnl >= 0 ? '+' : ''}${summary.totalPnl.toFixed(2)}

Return

= 0 ? 'text-green-400' : 'text-red-400'}`}> {summary.totalPnlPercent >= 0 ? '+' : ''}{summary.totalPnlPercent.toFixed(2)}%

)} {/* Agent Cards */}

Available Agents

{agents?.map((agent) => ( ))}
{/* Active Allocations */} {activeAllocations.length > 0 && (

Your Allocations

{activeAllocations.map((allocation) => ( ))}
)} {/* Info Section */} How It Works
1

Choose an Agent

Select based on your risk tolerance and return expectations

2

Allocate Funds

Transfer credits from your wallet to the agent

3

Earn Returns

Profits are distributed monthly after fees

{/* Allocation Modal */}
); };