From af2c86d9192cee9b4c458535489bca519fc2d699 Mon Sep 17 00:00:00 2001 From: sazzadulalambd Date: Sat, 9 May 2026 23:24:17 +0600 Subject: [PATCH] feat: add FICO share fields to investment plans and update UI for granular configuration --- src/app/admin/settings/page.tsx | 55 ++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/src/app/admin/settings/page.tsx b/src/app/admin/settings/page.tsx index 44f8a51..03cc53d 100644 --- a/src/app/admin/settings/page.tsx +++ b/src/app/admin/settings/page.tsx @@ -151,6 +151,9 @@ interface CompanySettings { targetAmount: number; status: string; description: string; + ficoSingleRent: number; + ficoRentToOwn: number; + ficoShareEv: number; }[]; swapStation: { id: string; @@ -560,6 +563,9 @@ const initialSettings: CompanySettings = { targetAmount: 1000000, status: 'active', description: 'Investment plan for 1 bike - perfect for small investors', + ficoSingleRent: 45, + ficoRentToOwn: 55, + ficoShareEv: 60, }, { id: 'inv_demo_2', @@ -578,7 +584,10 @@ const initialSettings: CompanySettings = { targetAmount: 5000000, status: 'active', description: 'Investment plan for 5 bikes - medium scale investment', - } + ficoSingleRent: 45, + ficoRentToOwn: 55, + ficoShareEv: 60, + }, ], swapStation: [ { @@ -690,11 +699,14 @@ export default function CompanySettingsPage() { const [newInvestLock, setNewInvestLock] = useState(3); const [newInvestTotal, setNewInvestTotal] = useState(24); const [newInvestPenalty, setNewInvestPenalty] = useState(10); + const [newInvestProfitShare, setNewInvestProfitShare] = useState(50); + const [newInvestFicoSingleRent, setNewInvestFicoSingleRent] = useState(45); + const [newInvestFicoRentToOwn, setNewInvestFicoRentToOwn] = useState(55); + const [newInvestFicoShareEv, setNewInvestFicoShareEv] = useState(60); 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, @@ -703,7 +715,7 @@ export default function CompanySettingsPage() { maxInvestment: newInvestMax, monthlyReturnPercent: newInvestMonthly, durationMonths: newInvestDuration, - profitSharePercent: ficoShare, + profitSharePercent: newInvestProfitShare, lockInMonths: newInvestLock, totalReturnPercent: newInvestTotal, earlyExitPenalty: newInvestPenalty, @@ -711,7 +723,10 @@ export default function CompanySettingsPage() { endDate: newInvestEnd, targetAmount: newInvestTarget, status: newInvestStatus, - description: newInvestDesc + description: newInvestDesc, + ficoSingleRent: newInvestFicoSingleRent, + ficoRentToOwn: newInvestFicoRentToOwn, + ficoShareEv: newInvestFicoShareEv, }; const updatedPlans = [...settings.plans.investment, newPlan]; setSettings({ ...settings, plans: { ...settings.plans, investment: updatedPlans } }); @@ -2611,10 +2626,18 @@ export default function CompanySettingsPage() { setNewInvestTotal(parseFloat(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}% +
+
+ + setNewInvestFicoSingleRent(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewInvestFicoRentToOwn(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewInvestFicoShareEv(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" />
@@ -2698,10 +2721,18 @@ export default function CompanySettingsPage() { { const updated = [...settings.plans.investment]; updated[idx].totalReturnPercent = parseFloat(e.target.value); setSettings({ ...settings, plans: { ...settings.plans, investment: updated } }); }} 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}% +
+
+ + { const updated = [...settings.plans.investment]; updated[idx].ficoSingleRent = parseInt(e.target.value); setSettings({ ...settings, plans: { ...settings.plans, investment: updated } }); }} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + { const updated = [...settings.plans.investment]; updated[idx].ficoRentToOwn = parseInt(e.target.value); setSettings({ ...settings, plans: { ...settings.plans, investment: updated } }); }} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + { const updated = [...settings.plans.investment]; updated[idx].ficoShareEv = parseInt(e.target.value); setSettings({ ...settings, plans: { ...settings.plans, investment: updated } }); }} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" />