'use client'; import { useState } from 'react'; import Link from 'next/link'; import { Target, Plus, Zap, ChevronRight, ArrowRight, Edit, Trash2, Eye, TrendingUp, X, CreditCard } from 'lucide-react'; import { investors } from '@/data/mockData'; import toast from 'react-hot-toast'; import InvestorNotification from '@/components/InvestorNotification'; export default function MyInvestmentsPage() { const investor = investors[0]; const [showCreateModal, setShowCreateModal] = useState(false); const [selectedTemplate, setSelectedTemplate] = useState(null); const [newInvestment, setNewInvestment] = useState({ planName: '', planType: 'gold', totalInvestment: 0, initialPayment: 0, paymentType: 'full', startDate: '', endDate: '', paymentMethod: 'bank', transactionReference: '', notes: '' }); const PLAN_TEMPLATES = [ { id: '1bike', name: '1 Bike Plan', tier: 'Standard', evBasePrice: 200000, minQuantity: 1, duration: 12, maxInvestment: 1000000 }, { id: '5bike', name: '5 Bike Plan', tier: 'Premium', evBasePrice: 180000, minQuantity: 5, duration: 24, maxInvestment: 5000000 }, { id: '10bike', name: '10 Bike Plan', tier: 'Enterprise', evBasePrice: 170000, minQuantity: 10, duration: 36, maxInvestment: 10000000 }, ]; const planConfig: Record = { silver: { bg: 'bg-slate-100', border: 'border-slate-300', icon: 'text-slate-500' }, gold: { bg: 'bg-amber-100', border: 'border-amber-300', icon: 'text-amber-500' }, platinum: { bg: 'bg-purple-100', border: 'border-purple-300', icon: 'text-purple-500' }, diamond: { bg: 'bg-blue-100', border: 'border-blue-300', icon: 'text-blue-500' }, }; const handleCreate = () => { if (!newInvestment.planName || !newInvestment.totalInvestment) { toast.error('Please fill all required fields'); return; } if (newInvestment.paymentType === 'partial' && newInvestment.initialPayment < newInvestment.totalInvestment * 0.5) { toast.error('Initial payment must be at least 50% of investment amount'); return; } toast.success(newInvestment.paymentType === 'partial' ? `Investment created! Initial: ৳${newInvestment.initialPayment.toLocaleString()}, Balance: ৳${(newInvestment.totalInvestment - newInvestment.initialPayment).toLocaleString()}` : 'Investment created successfully!' ); setShowCreateModal(false); setSelectedTemplate(null); setNewInvestment({ planName: '', planType: 'gold', totalInvestment: 0, initialPayment: 0, paymentType: 'full', startDate: '', endDate: '', paymentMethod: 'bank', transactionReference: '', notes: '' }); }; return (
{/* Header */}

My Investments

Manage your active portfolios and track your earnings.

{/* Investment Plans Cards */}

Investment Plans

Manage investment portfolios for this investor

{investor.investments?.map((inv) => { const style = planConfig[inv.planType] || planConfig.gold; return (

{inv.planName}

{inv.planType} Plan

{inv.status}

Investment

৳{inv.totalInvestment.toLocaleString()}

Total Return

৳{inv.actualEarnings.toLocaleString()}

Duration 12 months
Lock-in Period 3 months
Early Exit Penalty 10%
{inv.startDate} - {inv.endDate || 'Ongoing'} {inv.paymentMethod}

ID: #{inv.id?.slice(-6) || 'N/A'}

View
); })}
{(!investor.investments || investor.investments.length === 0) && (

No Investments Yet

Create your first investment plan

)}
{/* Create Investment Modal */} {showCreateModal && (

Create New Investment

Set up investment for {investor.name}

{!selectedTemplate ? ( <>
{PLAN_TEMPLATES.map(plan => ( ))}
) : ( <>
| {selectedTemplate.name}
setNewInvestment({ ...newInvestment, planName: e.target.value })} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm" placeholder="Plan name" />

= Qty × Base Price

setNewInvestment({ ...newInvestment, totalInvestment: Number(e.target.value) })} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm bg-yellow-50" />

Payment Options

{newInvestment.paymentType === 'partial' && (
{ const val = Number(e.target.value); if (val >= newInvestment.totalInvestment * 0.5 && val <= newInvestment.totalInvestment) { setNewInvestment({ ...newInvestment, initialPayment: val }); } }} className="w-full px-3 py-2 border border-investor rounded-lg text-sm bg-white" />

Balance: ৳{(newInvestment.totalInvestment - newInvestment.initialPayment).toLocaleString()}

)}

FICO Share - Profit per Ride

Profit sharing when bikes are rented to end customers

setNewInvestment({ ...newInvestment, startDate: e.target.value })} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm" />
setNewInvestment({ ...newInvestment, endDate: e.target.value })} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm" />
setNewInvestment({ ...newInvestment, transactionReference: e.target.value })} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm" placeholder="Auto-generated if empty" />