From 3297daf1246f83122dc9bbe8f1eedce0d10300a5 Mon Sep 17 00:00:00 2001 From: sazzadulalambd Date: Tue, 19 May 2026 16:00:27 +0600 Subject: [PATCH] refactor: simplify payment workflow by removing amount input and update sidebar profile navigation --- src/app/investor/investments/[id]/page.tsx | 112 +++++++-------------- src/app/investor/profile/page.tsx | 75 ++++++++------ src/components/Sidebar.tsx | 2 +- 3 files changed, 80 insertions(+), 109 deletions(-) diff --git a/src/app/investor/investments/[id]/page.tsx b/src/app/investor/investments/[id]/page.tsx index 9a47fbe..1293509 100644 --- a/src/app/investor/investments/[id]/page.tsx +++ b/src/app/investor/investments/[id]/page.tsx @@ -33,13 +33,14 @@ export default function InvestorInvestmentDetailPage({ params }: { params: Promi const [activeTab, setActiveTab] = useState('overview'); const [showPaymentModal, setShowPaymentModal] = useState(false); - const [paymentAmount, setPaymentAmount] = useState(''); const paymentHistory: PaymentRecord[] = [ - { id: 'pay1', date: '2024-01-15', amount: 400000, installmentNo: 1, type: 'installment', method: 'Bank Transfer', status: 'completed' }, - { id: 'pay2', date: '2024-02-15', amount: 150000, installmentNo: null, type: 'partial', method: 'bKash', status: 'completed' }, + { id: 'pay1', date: '2024-01-15', amount: Math.round((investment?.totalInvestment || 0) * 0.5), installmentNo: 1, type: 'installment', method: 'Bank Transfer', status: 'completed' }, + { id: 'pay2', date: '2024-02-15', amount: Math.round((investment?.totalInvestment || 0) * 0.25), installmentNo: null, type: 'partial', method: 'bKash', status: 'completed' }, ]; + + if (!investment) { return (
@@ -89,18 +90,9 @@ export default function InvestorInvestmentDetailPage({ params }: { params: Promi ]; const handlePaymentSubmit = () => { - const amount = parseFloat(paymentAmount); - if (!amount || amount <= 0) { - toast.error('Please enter a valid amount'); - return; - } - if (amount > dueAmount) { - toast.error('Amount exceeds due amount'); - return; - } + const amount = dueAmount; toast.success(`Payment of ৳${amount.toLocaleString()} submitted successfully!`); setShowPaymentModal(false); - setPaymentAmount(''); }; return ( @@ -146,7 +138,7 @@ export default function InvestorInvestmentDetailPage({ params }: { params: Promi
-
+
@@ -156,6 +148,20 @@ export default function InvestorInvestmentDetailPage({ params }: { params: Promi

৳{investment.totalInvestment.toLocaleString()}

+ +
+
+
+ +
+

Already Paid

+
+

৳{totalPaid.toLocaleString()}

+
+ + + +
@@ -165,18 +171,7 @@ export default function InvestorInvestmentDetailPage({ params }: { params: Promi

৳{investment.actualEarnings.toLocaleString()}

-
-
-
- -
-

Due Amount

-
-

৳{dueAmount.toLocaleString()}

- -
+
@@ -188,6 +183,7 @@ export default function InvestorInvestmentDetailPage({ params }: { params: Promi
+
{[ @@ -282,40 +278,7 @@ export default function InvestorInvestmentDetailPage({ params }: { params: Promi
-
-
-

- Payment History -

- -
-
- - - - - - - - - - - - {paymentHistory.map((payment) => ( - - - - - - - - ))} - -
DateTypeMethodAmountStatus
{payment.date}{payment.type}{payment.method}৳{payment.amount.toLocaleString()}{payment.status}
-
-
+
)} @@ -426,9 +389,12 @@ export default function InvestorInvestmentDetailPage({ params }: { params: Promi

{paymentHistory.length} payments made

- + {dueAmount > 0 && ( + + )} +
@@ -481,7 +447,7 @@ export default function InvestorInvestmentDetailPage({ params }: { params: Promi
- {showPaymentModal && ( + {showPaymentModal && dueAmount > 0 && (
@@ -506,19 +472,9 @@ export default function InvestorInvestmentDetailPage({ params }: { params: Promi
-
- -
- - setPaymentAmount(e.target.value)} - placeholder="Enter amount" - className="w-full pl-8 pr-4 py-3 border border-slate-200 rounded-xl text-lg font-semibold focus:outline-none focus:border-investor" /> -
-
- - - -
+
+

Fixed Payment Amount

+

৳{dueAmount.toLocaleString()}

@@ -536,7 +492,7 @@ export default function InvestorInvestmentDetailPage({ params }: { params: Promi
diff --git a/src/app/investor/profile/page.tsx b/src/app/investor/profile/page.tsx index 52885b9..4284826 100644 --- a/src/app/investor/profile/page.tsx +++ b/src/app/investor/profile/page.tsx @@ -12,6 +12,8 @@ import { import { investors } from '@/data/mockData'; import toast from 'react-hot-toast'; import InvestorNotification from '@/components/InvestorNotification'; +import { logout } from '@/lib/auth'; + function SectionCard({ title, icon: Icon, children, headerBg = 'bg-slate-50', headerBorder = 'border-slate-100', editKey, editingSection, setEditingSection, onEdit, editForm, setEditForm }: { title: string; icon: any; children: React.ReactNode; headerBg?: string; headerBorder?: string; editKey?: string; editingSection?: string | null; setEditingSection?: (s: string | null) => void; onEdit?: () => void; editForm?: any; setEditForm?: any @@ -116,6 +118,12 @@ export default function InvestorProfilePage() { setShowDeleteMobileModal(false); }; + const handleLogout = () => { + logout(); + window.location.href = '/login'; + }; + + const tabs = [ { id: 'personal', label: 'Personal Info', icon: User }, { id: 'nominee', label: 'Nominee & Emergency', icon: Heart }, @@ -131,40 +139,43 @@ export default function InvestorProfilePage() {
{/* Profile Header */}
-
-
-
- {investor.name.charAt(0)} +
+
+
+
+ {investor.name.charAt(0)} +
+
- -
-
-
-

{investor.name}

- - KYC {investor.kycStatus} - - - {investor.status} - - - Risk: {investor.riskLevel} - -
-

{investor.id} • {investor.email}

-
- Ref: {investor.referralCode} - {investor.totalReferrals} Referrals - • {investor.investments?.length || 0} Investments - • Referral Earnings: ৳{investor.referralEarnings?.toLocaleString() || 0} +
+
+

{investor.name}

+ + KYC {investor.kycStatus} + + + {investor.status} + + + Risk: {investor.riskLevel} + +
+

{investor.id} • {investor.email}

+
+ Ref: {investor.referralCode} + {investor.totalReferrals} Referrals + • {investor.investments?.length || 0} Investments + • Referral Earnings: ৳{investor.referralEarnings?.toLocaleString() || 0} +
+

Invested

@@ -922,10 +933,14 @@ export default function InvestorProfilePage() {

{session.location} • {session.time}

- {!session.current && } + {!session.current ? ( + + ) : ( + + )}
))} -
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 8b3c172..344042d 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -215,7 +215,7 @@ export default function Sidebar() {
- +
{userName.charAt(0).toUpperCase()}