refactor: remove investor portfolio and withdrawal pages and clean up related sidebar and admin navigation links.
This commit is contained in:
@@ -6,7 +6,8 @@ import { useRouter } from 'next/navigation';
|
||||
import {
|
||||
ArrowLeft, TrendingUp, Plus, X, Edit, Trash2, Bike, DollarSign, Calendar,
|
||||
CreditCard, FileText, Users, TrendingDown, ArrowRight, Download, Check,
|
||||
Printer, BarChart3, Wallet, Clock, Shield, Percent, Activity, AlertTriangle
|
||||
Printer, BarChart3, Wallet, Clock, Shield, Percent, Activity, AlertTriangle,
|
||||
Receipt, CreditCardIcon
|
||||
} from 'lucide-react';
|
||||
import { investors as initialInvestors, bikes as initialBikes, transactions as initialTransactions } from '@/data/mockData';
|
||||
|
||||
@@ -22,9 +23,27 @@ export default function InvestmentDetailPage({ params }: { params: Promise<{ id:
|
||||
const [showAddBikeModal, setShowAddBikeModal] = useState(false);
|
||||
const [showDeleteBikeModal, setShowDeleteBikeModal] = useState(false);
|
||||
const [showEditModal, setShowEditModal] = useState(false);
|
||||
const [showStatementHistory, setShowStatementHistory] = useState(false);
|
||||
const [showPartialPaymentModal, setShowPartialPaymentModal] = useState(false);
|
||||
const [bikeToDelete, setBikeToDelete] = useState<any>(null);
|
||||
const [selectedBikeId, setSelectedBikeId] = useState('');
|
||||
const [editForm, setEditForm] = useState<any>({});
|
||||
const [statementHistory, setStatementHistory] = useState<any[]>([
|
||||
{ id: 'stmt1', date: '2024-03-25', type: 'Monthly Statement', period: 'March 2024', downloadedBy: 'Admin', downloadedAt: '2024-03-25 10:30' },
|
||||
{ id: 'stmt2', date: '2024-02-28', type: 'Monthly Statement', period: 'February 2024', downloadedBy: 'Admin', downloadedAt: '2024-02-28 14:15' },
|
||||
{ id: 'stmt3', date: '2024-01-31', type: 'Monthly Statement', period: 'January 2024', downloadedBy: 'Admin', downloadedAt: '2024-01-31 09:00' },
|
||||
]);
|
||||
const [partialPayment, setPartialPayment] = useState({
|
||||
amount: 0,
|
||||
paymentMethod: 'bank',
|
||||
transactionRef: '',
|
||||
date: new Date().toISOString().split('T')[0],
|
||||
notes: ''
|
||||
});
|
||||
const [investmentPayments, setInvestmentPayments] = useState<any[]>([
|
||||
{ id: 'pay1', date: '2024-01-15', amount: 50000, paymentMethod: 'bank', transactionRef: 'TXN-001', status: 'completed', notes: 'First installment' },
|
||||
{ id: 'pay2', date: '2024-01-20', amount: 35000, paymentMethod: 'mobile', transactionRef: 'TXN-002', status: 'completed', notes: 'Second installment' },
|
||||
]);
|
||||
|
||||
if (!investor || !investment) {
|
||||
return (
|
||||
@@ -147,6 +166,12 @@ export default function InvestmentDetailPage({ params }: { params: Promise<{ id:
|
||||
>
|
||||
Transactions
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setActiveTab('payments')}
|
||||
className={`px-4 py-2 text-sm font-medium rounded-lg transition-colors ${activeTab === 'payments' ? 'bg-investor text-white' : 'text-slate-600 hover:bg-slate-100'}`}
|
||||
>
|
||||
Payments
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setActiveTab('pnl')}
|
||||
className={`px-4 py-2 text-sm font-medium rounded-lg transition-colors ${activeTab === 'pnl' ? 'bg-investor text-white' : 'text-slate-600 hover:bg-slate-100'}`}
|
||||
@@ -326,6 +351,73 @@ export default function InvestmentDetailPage({ params }: { params: Promise<{ id:
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === 'payments' && (
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<h4 className="font-semibold text-slate-800">Payment History</h4>
|
||||
<button
|
||||
onClick={() => setShowPartialPaymentModal(true)}
|
||||
className="px-3 py-1.5 text-xs bg-investor text-white rounded-lg flex items-center gap-1 hover:bg-investor-dark"
|
||||
>
|
||||
<Plus className="w-3 h-3" /> Record Payment
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="bg-slate-50 rounded-xl p-4">
|
||||
<div className="grid grid-cols-3 gap-4 mb-4">
|
||||
<div className="text-center">
|
||||
<p className="text-xs text-slate-500">Total Investment</p>
|
||||
<p className="text-lg font-bold text-slate-800">৳{investment.totalInvestment.toLocaleString()}</p>
|
||||
</div>
|
||||
<div className="text-center">
|
||||
<p className="text-xs text-slate-500">Paid Amount</p>
|
||||
<p className="text-lg font-bold text-green-600">৳{investmentPayments.reduce((sum, p) => sum + p.amount, 0).toLocaleString()}</p>
|
||||
</div>
|
||||
<div className="text-center">
|
||||
<p className="text-xs text-slate-500">Remaining</p>
|
||||
<p className="text-lg font-bold text-amber-600">৳{(investment.totalInvestment - investmentPayments.reduce((sum, p) => sum + p.amount, 0)).toLocaleString()}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="w-full bg-slate-200 rounded-full h-3 mb-4">
|
||||
<div
|
||||
className="bg-gradient-to-r from-green-500 to-green-600 h-3 rounded-full transition-all"
|
||||
style={{ width: `${Math.min(100, (investmentPayments.reduce((sum, p) => sum + p.amount, 0) / investment.totalInvestment) * 100)}%` }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-white rounded-xl border border-slate-200 overflow-hidden">
|
||||
<table className="w-full">
|
||||
<thead className="bg-slate-50">
|
||||
<tr>
|
||||
<th className="px-4 py-3 text-left text-xs font-medium text-slate-500">Date</th>
|
||||
<th className="px-4 py-3 text-left text-xs font-medium text-slate-500">Amount</th>
|
||||
<th className="px-4 py-3 text-left text-xs font-medium text-slate-500">Method</th>
|
||||
<th className="px-4 py-3 text-left text-xs font-medium text-slate-500">Reference</th>
|
||||
<th className="px-4 py-3 text-left text-xs font-medium text-slate-500">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-slate-100">
|
||||
{investmentPayments.map((payment: any) => (
|
||||
<tr key={payment.id}>
|
||||
<td className="px-4 py-3 text-sm text-slate-500">{payment.date}</td>
|
||||
<td className="px-4 py-3 text-sm font-bold text-green-600">৳{payment.amount.toLocaleString()}</td>
|
||||
<td className="px-4 py-3 text-sm capitalize">{payment.paymentMethod}</td>
|
||||
<td className="px-4 py-3 text-sm text-slate-500">{payment.transactionRef}</td>
|
||||
<td className="px-4 py-3">
|
||||
<span className={`px-2 py-1 rounded text-xs font-medium ${payment.status === 'completed' ? 'bg-green-100 text-green-700' : 'bg-amber-100 text-amber-700'}`}>
|
||||
{payment.status}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === 'journals' && (
|
||||
<div>
|
||||
<h4 className="font-semibold text-slate-800 mb-4">Accounting Journal Entries</h4>
|
||||
@@ -712,6 +804,192 @@ export default function InvestmentDetailPage({ params }: { params: Promise<{ id:
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{showStatementHistory && (
|
||||
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4">
|
||||
<div className="bg-white rounded-xl shadow-xl w-full max-w-lg">
|
||||
<div className="p-5 border-b border-slate-100 flex items-center justify-between">
|
||||
<h3 className="text-lg font-bold text-slate-800 flex items-center gap-2">
|
||||
<FileText className="w-5 h-5 text-investor" /> Statement History
|
||||
</h3>
|
||||
<button onClick={() => setShowStatementHistory(false)} className="p-1 hover:bg-slate-100 rounded-lg">
|
||||
<X className="w-5 h-5 text-slate-500" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="p-5">
|
||||
{statementHistory.length > 0 ? (
|
||||
<div className="space-y-3">
|
||||
{statementHistory.map((stmt: any) => (
|
||||
<div key={stmt.id} className="flex items-center gap-3 p-3 bg-slate-50 rounded-lg hover:bg-slate-100 transition-colors">
|
||||
<div className="w-10 h-10 bg-purple-100 rounded-lg flex items-center justify-center">
|
||||
<FileText className="w-5 h-5 text-purple-600" />
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<p className="text-sm font-medium text-slate-800">{stmt.type}</p>
|
||||
<p className="text-xs text-slate-500">{stmt.period}</p>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<p className="text-xs text-slate-400">{stmt.downloadedAt}</p>
|
||||
<p className="text-xs text-slate-500">by {stmt.downloadedBy}</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-center py-8">
|
||||
<FileText className="w-10 h-10 mx-auto mb-3 text-slate-300" />
|
||||
<p className="text-slate-500">No statements generated yet</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="p-5 border-t border-slate-100 flex justify-end">
|
||||
<button onClick={() => setShowStatementHistory(false)} className="px-4 py-2 border border-slate-200 text-slate-600 rounded-lg text-sm hover:bg-slate-50">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{showPartialPaymentModal && (
|
||||
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4">
|
||||
<div className="bg-white rounded-xl shadow-xl w-full max-w-lg">
|
||||
<div className="p-5 border-b border-slate-100 flex items-center justify-between">
|
||||
<h3 className="text-lg font-bold text-slate-800 flex items-center gap-2">
|
||||
<CreditCardIcon className="w-5 h-5 text-investor" /> Record Partial Payment
|
||||
</h3>
|
||||
<button onClick={() => setShowPartialPaymentModal(false)} className="p-1 hover:bg-slate-100 rounded-lg">
|
||||
<X className="w-5 h-5 text-slate-500" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="p-5 space-y-4">
|
||||
<div className="bg-amber-50 border border-amber-200 rounded-lg p-4">
|
||||
<div className="flex justify-between items-center">
|
||||
<span className="text-sm text-slate-600">Total Investment</span>
|
||||
<span className="font-bold text-slate-800">৳{investment.totalInvestment.toLocaleString()}</span>
|
||||
</div>
|
||||
<div className="flex justify-between items-center mt-2">
|
||||
<span className="text-sm text-slate-600">Already Paid</span>
|
||||
<span className="font-bold text-green-600">৳{investmentPayments.reduce((sum, p) => sum + p.amount, 0).toLocaleString()}</span>
|
||||
</div>
|
||||
<div className="flex justify-between items-center mt-2 pt-2 border-t border-amber-200">
|
||||
<span className="text-sm font-semibold text-slate-700">Remaining</span>
|
||||
<span className="font-bold text-amber-600">৳{(investment.totalInvestment - investmentPayments.reduce((sum, p) => sum + p.amount, 0)).toLocaleString()}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="text-sm font-medium text-slate-700 mb-1 block">Amount (৳) <span className="text-red-500">*</span></label>
|
||||
<input
|
||||
type="number"
|
||||
value={partialPayment.amount || ''}
|
||||
onChange={(e) => setPartialPayment({ ...partialPayment, amount: Number(e.target.value) })}
|
||||
className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-investor"
|
||||
placeholder="Enter payment amount"
|
||||
/>
|
||||
<p className="text-xs text-slate-400 mt-1">Minimum: ৳1,000</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="text-sm font-medium text-slate-700 mb-1 block">Date</label>
|
||||
<input
|
||||
type="date"
|
||||
value={partialPayment.date}
|
||||
onChange={(e) => setPartialPayment({ ...partialPayment, date: e.target.value })}
|
||||
className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-investor"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-sm font-medium text-slate-700 mb-1 block">Payment Method</label>
|
||||
<select
|
||||
value={partialPayment.paymentMethod}
|
||||
onChange={(e) => setPartialPayment({ ...partialPayment, paymentMethod: e.target.value })}
|
||||
className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-investor"
|
||||
>
|
||||
<option value="bank">Bank Transfer</option>
|
||||
<option value="mobile">Mobile Banking</option>
|
||||
<option value="cash">Cash</option>
|
||||
<option value="cheque">Cheque</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="text-sm font-medium text-slate-700 mb-1 block">Transaction Reference</label>
|
||||
<input
|
||||
type="text"
|
||||
value={partialPayment.transactionRef}
|
||||
onChange={(e) => setPartialPayment({ ...partialPayment, transactionRef: e.target.value })}
|
||||
className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-investor"
|
||||
placeholder="e.g., TXN-12345"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="text-sm font-medium text-slate-700 mb-1 block">Notes</label>
|
||||
<textarea
|
||||
value={partialPayment.notes}
|
||||
onChange={(e) => setPartialPayment({ ...partialPayment, notes: e.target.value })}
|
||||
className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-investor"
|
||||
rows={2}
|
||||
placeholder="Optional notes for this payment"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="bg-green-50 border border-green-200 rounded-lg p-3">
|
||||
<h4 className="text-xs font-semibold text-green-800 mb-2">Journal Entry Preview</h4>
|
||||
<div className="space-y-1 text-xs">
|
||||
<div className="flex justify-between">
|
||||
<span className="text-green-600">Dr: Bank - City Bank (1200)</span>
|
||||
<span className="font-medium">৳{partialPayment.amount?.toLocaleString() || 0}</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<span className="text-blue-600">Cr: Investor Liabilities (2200)</span>
|
||||
<span className="font-medium">৳{partialPayment.amount?.toLocaleString() || 0}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="p-5 border-t border-slate-100 flex justify-end gap-3">
|
||||
<button onClick={() => setShowPartialPaymentModal(false)} className="px-4 py-2 border border-slate-200 text-slate-600 rounded-lg text-sm hover:bg-slate-50">
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
if (partialPayment.amount <= 0) {
|
||||
alert('Please enter a valid amount');
|
||||
return;
|
||||
}
|
||||
const newPayment = {
|
||||
id: `pay${Date.now()}`,
|
||||
date: partialPayment.date,
|
||||
amount: partialPayment.amount,
|
||||
paymentMethod: partialPayment.paymentMethod,
|
||||
transactionRef: partialPayment.transactionRef || `AUTO-${Date.now()}`,
|
||||
status: 'completed',
|
||||
notes: partialPayment.notes
|
||||
};
|
||||
setInvestmentPayments([...investmentPayments, newPayment]);
|
||||
setPartialPayment({
|
||||
amount: 0,
|
||||
paymentMethod: 'bank',
|
||||
transactionRef: '',
|
||||
date: new Date().toISOString().split('T')[0],
|
||||
notes: ''
|
||||
});
|
||||
setShowPartialPaymentModal(false);
|
||||
alert('Payment recorded successfully!');
|
||||
}}
|
||||
disabled={partialPayment.amount <= 0}
|
||||
className="px-4 py-2 bg-investor text-white rounded-lg text-sm font-medium hover:bg-investor-dark disabled:opacity-50"
|
||||
>
|
||||
Record Payment
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -141,6 +141,17 @@ export default function InvestorDetailPage() {
|
||||
transactionReference: '',
|
||||
notes: ''
|
||||
});
|
||||
const [showAddPaymentModal, setShowAddPaymentModal] = useState(false);
|
||||
const [newPayment, setNewPayment] = useState({
|
||||
amount: 0,
|
||||
paymentMethod: 'bank' as 'bank' | 'mobile' | 'cash' | 'cheque',
|
||||
transactionRef: '',
|
||||
date: new Date().toISOString().split('T')[0],
|
||||
notes: ''
|
||||
});
|
||||
const [investmentPayments, setInvestmentPayments] = useState<any[]>([
|
||||
{ id: 'pay1', date: '2024-01-15', amount: 50000, paymentMethod: 'bank', transactionRef: 'TXN-001', status: 'completed', notes: 'First payment' }
|
||||
]);
|
||||
|
||||
if (!investor) {
|
||||
return (
|
||||
@@ -3006,6 +3017,106 @@ export default function InvestorDetailPage() {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{showAddPaymentModal && (
|
||||
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4">
|
||||
<div className="bg-white rounded-xl shadow-xl w-full max-w-lg">
|
||||
<div className="p-5 border-b border-slate-100 flex items-center justify-between">
|
||||
<h3 className="text-lg font-bold text-slate-800 flex items-center gap-2">
|
||||
<CreditCard className="w-5 h-5 text-investor" /> Record Payment
|
||||
</h3>
|
||||
<button onClick={() => setShowAddPaymentModal(false)} className="p-1 hover:bg-slate-100 rounded-lg">
|
||||
<X className="w-5 h-5 text-slate-500" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="p-5 space-y-4">
|
||||
<div>
|
||||
<label className="text-sm font-medium text-slate-700 mb-1 block">Amount (৳) <span className="text-red-500">*</span></label>
|
||||
<input
|
||||
type="number"
|
||||
value={newPayment.amount || ''}
|
||||
onChange={(e) => setNewPayment({ ...newPayment, amount: Number(e.target.value) })}
|
||||
className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-investor"
|
||||
placeholder="Enter payment amount"
|
||||
/>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="text-sm font-medium text-slate-700 mb-1 block">Date</label>
|
||||
<input
|
||||
type="date"
|
||||
value={newPayment.date}
|
||||
onChange={(e) => setNewPayment({ ...newPayment, date: e.target.value })}
|
||||
className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-investor"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-sm font-medium text-slate-700 mb-1 block">Payment Method</label>
|
||||
<select
|
||||
value={newPayment.paymentMethod}
|
||||
onChange={(e) => setNewPayment({ ...newPayment, paymentMethod: e.target.value as any })}
|
||||
className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-investor"
|
||||
>
|
||||
<option value="bank">Bank Transfer</option>
|
||||
<option value="mobile">Mobile Banking</option>
|
||||
<option value="cash">Cash</option>
|
||||
<option value="cheque">Cheque</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-sm font-medium text-slate-700 mb-1 block">Transaction Reference</label>
|
||||
<input
|
||||
type="text"
|
||||
value={newPayment.transactionRef}
|
||||
onChange={(e) => setNewPayment({ ...newPayment, transactionRef: e.target.value })}
|
||||
className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-investor"
|
||||
placeholder="e.g., TXN-12345"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-sm font-medium text-slate-700 mb-1 block">Notes</label>
|
||||
<textarea
|
||||
value={newPayment.notes}
|
||||
onChange={(e) => setNewPayment({ ...newPayment, notes: e.target.value })}
|
||||
className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-investor"
|
||||
rows={2}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="p-5 border-t border-slate-100 flex justify-end gap-3">
|
||||
<button onClick={() => setShowAddPaymentModal(false)} className="px-4 py-2 border border-slate-200 text-slate-600 rounded-lg text-sm hover:bg-slate-50">
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
if (newPayment.amount <= 0) {
|
||||
alert('Please enter a valid amount');
|
||||
return;
|
||||
}
|
||||
const payment = {
|
||||
id: `pay${Date.now()}`,
|
||||
date: newPayment.date,
|
||||
amount: newPayment.amount,
|
||||
paymentMethod: newPayment.paymentMethod,
|
||||
transactionRef: newPayment.transactionRef || `AUTO-${Date.now()}`,
|
||||
status: 'completed',
|
||||
notes: newPayment.notes
|
||||
};
|
||||
setInvestmentPayments([...investmentPayments, payment]);
|
||||
setNewPayment({ amount: 0, paymentMethod: 'bank', transactionRef: '', date: new Date().toISOString().split('T')[0], notes: '' });
|
||||
setShowAddPaymentModal(false);
|
||||
alert('Payment recorded successfully!');
|
||||
}}
|
||||
disabled={newPayment.amount <= 0}
|
||||
className="px-4 py-2 bg-investor text-white rounded-lg text-sm font-medium hover:bg-investor-dark disabled:opacity-50"
|
||||
>
|
||||
Record Payment
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user