From 928350b478a8ba9aa5952291e7c87aa3cc1c6b2d Mon Sep 17 00:00:00 2001 From: sazzadulalambd Date: Tue, 5 May 2026 21:48:18 +0600 Subject: [PATCH] feat: add investment plan management section to company settings --- src/app/admin/settings/page.tsx | 298 +++++++++++++++++++++++++++++++- 1 file changed, 294 insertions(+), 4 deletions(-) diff --git a/src/app/admin/settings/page.tsx b/src/app/admin/settings/page.tsx index 813827f..25ac10b 100644 --- a/src/app/admin/settings/page.tsx +++ b/src/app/admin/settings/page.tsx @@ -1,7 +1,7 @@ 'use client'; import { useState } from 'react'; -import { Settings, Upload, Image, Globe, Mail, MessageSquare, Phone, MapPin, Link2, Clock, Save, FileText, Camera, Palette, Ruler, Sun, Moon, Monitor, Smartphone, Tablet, Package, Wrench, FileCheck, BadgeDollarSign, CreditCard } from 'lucide-react'; +import { Settings, Upload, Image, Globe, Mail, MessageSquare, Phone, MapPin, Link2, Clock, Save, FileText, Camera, Palette, Ruler, Sun, Moon, Monitor, Smartphone, Tablet, Package, Wrench, FileCheck, BadgeDollarSign, CreditCard, Plus, X, DollarSign } from 'lucide-react'; interface CompanySettings { name: string; @@ -120,6 +120,24 @@ interface CompanySettings { ficoSharePercent: number; description: string; }[]; + investment: { + id: string; + tier: string; + name: string; + minInvestment: number; + maxInvestment: number; + monthlyReturnPercent: number; + durationMonths: number; + profitSharePercent: number; + lockInMonths: number; + totalReturnPercent: number; + earlyExitPenalty: number; + startDate: string; + endDate: string; + targetAmount: number; + status: string; + description: string; + }[]; }; } @@ -439,18 +457,101 @@ const initialSettings: CompanySettings = { description: 'Economy shared EV plan', } ], + investment: [ + { + id: 'inv_demo_1', + name: '1 Bike Plan', + tier: 'Economy', + minInvestment: 50000, + maxInvestment: 100000, + monthlyReturnPercent: 2, + durationMonths: 12, + profitSharePercent: 50, + lockInMonths: 3, + totalReturnPercent: 24, + earlyExitPenalty: 10, + startDate: '2026-01-01', + endDate: '2026-12-31', + targetAmount: 1000000, + status: 'active', + description: 'Investment plan for 1 bike - perfect for small investors', + }, + { + id: 'inv_demo_2', + name: '5 Bike Plan', + tier: 'Standard', + minInvestment: 150000, + maxInvestment: 500000, + monthlyReturnPercent: 2.5, + durationMonths: 24, + profitSharePercent: 50, + lockInMonths: 6, + totalReturnPercent: 60, + earlyExitPenalty: 10, + startDate: '2026-01-01', + endDate: '2026-12-31', + targetAmount: 5000000, + status: 'active', + description: 'Investment plan for 5 bikes - medium scale investment', + } + ], }, }; export default function CompanySettingsPage() { const [settings, setSettings] = useState(initialSettings); - const [activeTab, setActiveTab] = useState<'general' | 'branding' | 'social' | 'integration' | 'landing' | 'kyc' | 'parts' | 'rental' | 'plans'>('general'); + const [activeTab, setActiveTab] = useState<'general' | 'branding' | 'social' | 'integration' | 'landing' | 'kyc' | 'parts' | 'rental' | 'plans' | 'investment'>('general'); const [activeMasterTab, setActiveMasterTab] = useState<'investor' | 'merchant' | 'swapstation' | 'rental'>('investor'); const [saved, setSaved] = useState(false); const [activePlanTab, setActivePlanTab] = useState<'singleRent' | 'rentToOwn' | 'shareEv'>('singleRent'); const [addDocType, setAddDocType] = useState<'investor' | 'merchant' | 'swapstation' | 'rental' | null>(null); const [newDocName, setNewDocName] = useState(''); const [newDocDesc, setNewDocDesc] = useState(''); + const [activeInvestTab, setActiveInvestTab] = useState(0); + const [addInvestPlan, setAddInvestPlan] = useState(false); + const [newInvestName, setNewInvestName] = useState(''); + const [newInvestTier, setNewInvestTier] = useState('Standard'); + const [newInvestStatus, setNewInvestStatus] = useState('active'); + const [newInvestTarget, setNewInvestTarget] = useState(1000000); + const [newInvestStart, setNewInvestStart] = useState('2026-01-01'); + const [newInvestEnd, setNewInvestEnd] = useState('2026-12-31'); + const [newInvestMin, setNewInvestMin] = useState(10000); + const [newInvestMax, setNewInvestMax] = useState(100000); + const [newInvestMonthly, setNewInvestMonthly] = useState(2); + const [newInvestDuration, setNewInvestDuration] = useState(12); + const [newInvestLock, setNewInvestLock] = useState(3); + const [newInvestTotal, setNewInvestTotal] = useState(24); + const [newInvestPenalty, setNewInvestPenalty] = useState(10); + const [newInvestDesc, setNewInvestDesc] = useState(''); + + const createInvestPlan = () => { + if (newInvestName.trim() && typeof window !== 'undefined') { + const ficoShare = settings.plans.singleRent[0]?.ficoSharePercent || 50; + const newPlan = { + id: 'inv_' + Date.now(), + name: newInvestName, + tier: newInvestTier, + minInvestment: newInvestMin, + maxInvestment: newInvestMax, + monthlyReturnPercent: newInvestMonthly, + durationMonths: newInvestDuration, + profitSharePercent: ficoShare, + lockInMonths: newInvestLock, + totalReturnPercent: newInvestTotal, + earlyExitPenalty: newInvestPenalty, + startDate: newInvestStart, + endDate: newInvestEnd, + targetAmount: newInvestTarget, + status: newInvestStatus, + description: newInvestDesc + }; + const updatedPlans = [...settings.plans.investment, newPlan]; + setSettings({ ...settings, plans: { ...settings.plans, investment: updatedPlans } }); + setActiveInvestTab(updatedPlans.length - 1); + setAddInvestPlan(false); + setNewInvestName(''); + } + }; const handleSave = () => { setSaved(true); @@ -467,6 +568,7 @@ export default function CompanySettingsPage() { { id: 'parts', label: 'EV Parts', icon: Package }, { id: 'rental', label: 'Rental Policy', icon: FileCheck }, { id: 'plans', label: 'Plan Selection', icon: Package }, + { id: 'investment', label: 'Investment Plan', icon: DollarSign }, ]; return ( @@ -476,12 +578,12 @@ export default function CompanySettingsPage() {

Company Settings

Manage your company information and configurations

- + */} {saved && ( @@ -1772,6 +1874,194 @@ export default function CompanySettingsPage() { )} )} + + {(activeTab as string) === 'investment' && ( +
+
+

Investment Plans

+
+ +
+
+

Investment Plans ({settings.plans.investment.length})

+

Manage investment plans for investors

+
+ +
+ + {addInvestPlan && ( +
+
+
+

New Investment Plan

+

Fill in the details below

+
+ +
+
+
+
+ + setNewInvestName(e.target.value)} placeholder="e.g., 1 Bike Plan" className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + +
+
+ + setNewInvestTarget(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewInvestStart(e.target.value)} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewInvestEnd(e.target.value)} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewInvestMin(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewInvestMax(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewInvestMonthly(parseFloat(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewInvestDuration(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewInvestLock(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewInvestTotal(parseFloat(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewInvestPenalty(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+
+
+ Profit from Plan Selection (FICO Share): + {settings.plans.singleRent[0]?.ficoSharePercent || 50}% +
+
+
+ +