diff --git a/src/app/admin/rentals/page.tsx b/src/app/admin/rentals/page.tsx
index cdd643e..97a25be 100644
--- a/src/app/admin/rentals/page.tsx
+++ b/src/app/admin/rentals/page.tsx
@@ -272,6 +272,7 @@ export default function RentalsPage() {
const [editPermission, setEditPermission] = useState(false);
const [lockPermission, setLockPermission] = useState(false);
const [unlockPermission, setUnlockPermission] = useState(false);
+ const [lockUnlockRental, setLockUnlockRental] = useState<{ id: string; action: 'lock' | 'unlock' } | null>(null);
const [planConditions, setPlanConditions] = useState<{
single: { name: string; deposit: number; dailyRate: number; weeklyRate: number; monthlyRate: number; contractMonths: number[]; evModels: string[] }[];
shared: { name: string; deposit: number; dailyRate: number; weeklyRate: number; monthlyRate: number; contractMonths: number[]; evModels: string[] }[];
@@ -503,38 +504,38 @@ export default function RentalsPage() {
Rentals
Manage rental transactions
-
+
{createPermission && (
setShowCreateModal(true)}
- className="py-2 px-4 bg-emerald-600 text-white rounded-lg text-sm font-semibold hover:bg-emerald-700 flex items-center gap-2"
+ className="py-2 px-4 bg-emerald-600 text-white rounded-lg text-sm font-semibold hover:bg-emerald-700 flex items-center justify-center gap-2"
>
New Rental
)}
-
+
Export
-
+
setStatusFilter(statusFilter === 'active' ? 'all' : 'active')} className={`text-left bg-white rounded-xl p-4 shadow-sm border transition-all ${statusFilter === 'active' ? 'border-emerald-500 ring-2 ring-emerald-100' : 'border-slate-100 hover:border-emerald-200'}`}>
{stats.active}
- Active
-
-
+
Active Rentals
+
+
setStatusFilter(statusFilter === 'pending' ? 'all' : 'pending')} className={`text-left bg-white rounded-xl p-4 shadow-sm border transition-all ${statusFilter === 'pending' ? 'border-amber-500 ring-2 ring-amber-100' : 'border-slate-100 hover:border-amber-200'}`}>
{stats.pending}
- Pending
-
-
+
Payment Due (Day1)
+
+
setStatusFilter(statusFilter === 'overdue' ? 'all' : 'overdue')} className={`text-left bg-white rounded-xl p-4 shadow-sm border transition-all ${statusFilter === 'overdue' ? 'border-orange-500 ring-2 ring-orange-100' : 'border-slate-100 hover:border-orange-200'}`}>
{stats.overdue}
- Payment Issues
-
-
+
Payment Due (Day2)
+
+
setStatusFilter(statusFilter === 'locked' ? 'all' : 'locked')} className={`text-left bg-white rounded-xl p-4 shadow-sm border transition-all ${statusFilter === 'locked' ? 'border-red-500 ring-2 ring-red-100' : 'border-slate-100 hover:border-red-200'}`}>
{stats.locked}
- Locked
-
+
EV Locked
+
@@ -575,7 +576,7 @@ export default function RentalsPage() {
-
+
@@ -587,7 +588,6 @@ export default function RentalsPage() {
Hub
Deposit
Rent Payment
- {/* Penalty */}
Status
Actions
@@ -596,7 +596,6 @@ export default function RentalsPage() {
{filteredRentals.map(rental => {
const statusBadge = getStatusBadge(rental.status);
const paymentBadge = getPaymentStatusBadge(rental.paymentStatus, rental.pendingRent, rental.pendingRentDays);
- const penaltyBadge = getPenaltyBadge(rental.penaltyLevel);
const typeBadge = getTypeBadge(rental.type);
return (
@@ -671,14 +670,13 @@ export default function RentalsPage() {
-
{lockPermission && rental.status === 'active' && (
-
+ setLockUnlockRental({ id: rental.id, action: 'lock' })} className="p-1.5 hover:bg-red-100 rounded-lg" title="Lock">
)}
{unlockPermission && rental.status === 'locked' && (
-
+ setLockUnlockRental({ id: rental.id, action: 'unlock' })} className="p-1.5 hover:bg-green-100 rounded-lg" title="Unlock">
)}
@@ -696,6 +694,92 @@ export default function RentalsPage() {
+
+
+ {filteredRentals.map(rental => {
+ const statusBadge = getStatusBadge(rental.status);
+ const paymentBadge = getPaymentStatusBadge(rental.paymentStatus, rental.pendingRent, rental.pendingRentDays);
+ const typeBadge = getTypeBadge(rental.type);
+ return (
+
+
+
+ {rental.id}
+
+
+ {statusBadge.label}
+
+
+
+
+
+
+
{rental.bikeModel}
+
{rental.bikePlate}
+
+
+
+
+
+
+
{rental.userName}
+
{rental.userPhone}
+
+
+
+
+
+ {typeBadge.label}
+
+ {rental.subscriptionType}
+ •
+ {rental.hubName}
+
+
+
+
+ Deposit:
+ ৳{rental.deposit.toLocaleString()}
+
+ {rental.depositPaid ? 'Paid' : 'Unpaid'}
+
+
+ {(paymentBadge.pendingRent && paymentBadge.pendingRent > 0) ? (
+
+ ৳{paymentBadge.pendingRent}
+
+ ) : (
+
+ Clear
+
+ )}
+
+
+
+
+
View
+
+ {lockPermission && rental.status === 'active' && (
+
setLockUnlockRental({ id: rental.id, action: 'lock' })} className="flex-1 flex items-center justify-center gap-1 p-2 bg-white hover:bg-red-50 rounded-lg text-xs font-medium text-red-600">
+ Lock
+
+ )}
+ {unlockPermission && rental.status === 'locked' && (
+
setLockUnlockRental({ id: rental.id, action: 'unlock' })} className="flex-1 flex items-center justify-center gap-1 p-2 bg-white hover:bg-green-50 rounded-lg text-xs font-medium text-green-600">
+ Unlock
+
+ )}
+
+ Call
+
+
+ SMS
+
+
+
+ );
+ })}
+
{showCreateModal && (
@@ -916,20 +1000,20 @@ export default function RentalsPage() {
{newRental.depositPaymentMethod === 'bank' && '1100 - Bank'}
{newRental.depositPaymentMethod === 'wallet' && '1200 - Biker Wallet'}
-
{newRental.depositAmount > 0 ? newRental.depositAmount.toLocaleString() : selectedPlan?.deposit.toLocaleString()}
-
-
-
-
- 2100 - Deposit Received
- -
- {newRental.depositAmount > 0 ? newRental.depositAmount.toLocaleString() : selectedPlan?.deposit.toLocaleString()}
-
-
-
-
- Total
- {newRental.depositAmount > 0 ? newRental.depositAmount.toLocaleString() : selectedPlan?.deposit.toLocaleString()}
- {newRental.depositAmount > 0 ? newRental.depositAmount.toLocaleString() : selectedPlan?.deposit.toLocaleString()}
+ {newRental.depositAmount > 0 ? newRental.depositAmount.toLocaleString() : selectedPlan?.deposit.toLocaleString()}
+ -
+
+
+ 2100 - Deposit Received
+ -
+ {newRental.depositAmount > 0 ? newRental.depositAmount.toLocaleString() : selectedPlan?.deposit.toLocaleString()}
+
+
+
+
+ Total
+ {newRental.depositAmount > 0 ? newRental.depositAmount.toLocaleString() : selectedPlan?.deposit.toLocaleString()}
+ {newRental.depositAmount > 0 ? newRental.depositAmount.toLocaleString() : selectedPlan?.deposit.toLocaleString()}
@@ -982,6 +1066,43 @@ export default function RentalsPage() {
)}
+
+ {lockUnlockRental && (
+
+
+
+
+ {lockUnlockRental.action === 'lock' ? : }
+
+
+ {lockUnlockRental.action === 'lock' ? 'Lock EV?' : 'Unlock EV?'}
+
+
+ {lockUnlockRental.action === 'lock'
+ ? 'This will lock the EV and prevent the rider from starting it. Are you sure?'
+ : 'This will unlock the EV and allow the rider to start it. Are you sure?'}
+
+
+ setLockUnlockRental(null)}
+ className="flex-1 py-2.5 px-4 border border-slate-200 rounded-lg text-sm font-medium text-slate-600 hover:bg-slate-50"
+ >
+ Cancel
+
+ {
+ setRentals(prev => prev.map(r => r.id === lockUnlockRental.id ? { ...r, status: lockUnlockRental.action === 'lock' ? 'locked' : 'active' } : r));
+ setLockUnlockRental(null);
+ }}
+ className={`flex-1 py-2.5 px-4 rounded-lg text-sm font-semibold text-white ${lockUnlockRental.action === 'lock' ? 'bg-red-600 hover:bg-red-700' : 'bg-green-600 hover:bg-green-700'}`}
+ >
+ Confirm
+
+
+
+
+
+ )}
);
}