feat: add FICO share fields to investment plans and update UI for granular configuration

This commit is contained in:
sazzadulalambd
2026-05-09 23:24:17 +06:00
parent fd7b1ab824
commit af2c86d919

View File

@@ -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() {
<input type="number" step="0.1" value={newInvestTotal} onChange={(e) => setNewInvestTotal(parseFloat(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" />
</div>
</div>
<div className="mt-4 p-3 bg-slate-50 rounded-lg">
<div className="flex items-center justify-between text-sm">
<span className="text-slate-600">Profit from Plan Selection (FICO Share):</span>
<span className="font-semibold text-green-600">{settings.plans.singleRent[0]?.ficoSharePercent || 50}%</span>
<div className="grid grid-cols-3 gap-4 mt-4">
<div>
<label className="text-sm text-slate-600">FICO Share (%) - Single Rent</label>
<input type="number" value={newInvestFicoSingleRent} onChange={(e) => setNewInvestFicoSingleRent(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" />
</div>
<div>
<label className="text-sm text-slate-600">FICO Share (%) - Rent to Own</label>
<input type="number" value={newInvestFicoRentToOwn} onChange={(e) => setNewInvestFicoRentToOwn(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" />
</div>
<div>
<label className="text-sm text-slate-600">FICO Share (%) - Share an EV</label>
<input type="number" value={newInvestFicoShareEv} onChange={(e) => setNewInvestFicoShareEv(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" />
</div>
</div>
<div className="mt-4">
@@ -2698,10 +2721,18 @@ export default function CompanySettingsPage() {
<input type="number" step="0.1" value={plan.totalReturnPercent} onChange={(e) => { 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" />
</div>
</div>
<div className="mt-4 p-3 bg-slate-50 rounded-lg">
<div className="flex items-center justify-between text-sm">
<span className="text-slate-600">Profit from Plan Selection (FICO Share):</span>
<span className="font-semibold text-green-600">{settings.plans.singleRent[0]?.ficoSharePercent || 50}%</span>
<div className="grid grid-cols-3 gap-4 mt-4">
<div>
<label className="text-sm text-slate-600">FICO Share (%) - Single Rent</label>
<input type="number" value={(plan as any).ficoSingleRent} onChange={(e) => { 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" />
</div>
<div>
<label className="text-sm text-slate-600">FICO Share (%) - Rent to Own</label>
<input type="number" value={(plan as any).ficoRentToOwn} onChange={(e) => { 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" />
</div>
<div>
<label className="text-sm text-slate-600">FICO Share (%) - Share an EV</label>
<input type="number" value={(plan as any).ficoShareEv} onChange={(e) => { 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" />
</div>
</div>
<div className="mt-4">