From 4ee6944f9d60f9c06441cb41a34d785a08f02ecd Mon Sep 17 00:00:00 2001 From: sazzadulalambd Date: Sun, 10 May 2026 03:11:49 +0600 Subject: [PATCH] feat: add EV model selection and deposit tracking to rental management workflow --- src/app/admin/rentals/page.tsx | 150 +++++++++++++++++++-------------- 1 file changed, 85 insertions(+), 65 deletions(-) diff --git a/src/app/admin/rentals/page.tsx b/src/app/admin/rentals/page.tsx index 9700537..191c910 100644 --- a/src/app/admin/rentals/page.tsx +++ b/src/app/admin/rentals/page.tsx @@ -273,24 +273,24 @@ export default function RentalsPage() { const [lockPermission, setLockPermission] = useState(false); const [unlockPermission, setUnlockPermission] = useState(false); const [planConditions, setPlanConditions] = useState<{ - single: { name: string; deposit: number; dailyRate: number; weeklyRate: number; monthlyRate: number; contractMonths: number[] }[]; - shared: { name: string; deposit: number; dailyRate: number; weeklyRate: number; monthlyRate: number; contractMonths: number[] }[]; - 'rent-to-own': { name: string; deposit: number; dailyRate: number; weeklyRate: number; monthlyRate: number; contractMonths: number[] }[]; + 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[] }[]; + 'rent-to-own': { name: string; deposit: number; dailyRate: number; weeklyRate: number; monthlyRate: number; contractMonths: number[]; evModels: string[] }[]; }>({ single: [ - { name: 'Single Rent - Premium', deposit: 25000, dailyRate: 400, weeklyRate: 2800, monthlyRate: 12000, contractMonths: [1, 3, 6, 12] }, - { name: 'Single Rent - Standard', deposit: 20000, dailyRate: 300, weeklyRate: 2100, monthlyRate: 9000, contractMonths: [1, 3, 6, 12] }, - { name: 'Single Rent - Economy', deposit: 15000, dailyRate: 250, weeklyRate: 1750, monthlyRate: 7500, contractMonths: [1, 3, 6, 12] }, + { name: 'Single Rent - Premium', deposit: 25000, dailyRate: 400, weeklyRate: 2800, monthlyRate: 12000, contractMonths: [1, 3, 6, 12], evModels: ['Yadea G5', 'Yadea C1S', 'Himiwa 400', 'Himiwa 500', 'Himiwa 600', 'TVS iQube', 'Bexly 1S', 'Bexly 3S', 'Bexly 5E', 'Bolan E-Bike', 'Nova E-Bike', 'Super Eco', 'Other'] }, + { name: 'Single Rent - Standard', deposit: 20000, dailyRate: 300, weeklyRate: 2100, monthlyRate: 9000, contractMonths: [1, 3, 6, 12], evModels: ['Yadea G5', 'Yadea C1S', 'Himiwa 400', 'Himiwa 500', 'Himiwa 600', 'TVS iQube', 'Bexly 1S', 'Bexly 3S', 'Bexly 5E', 'Bolan E-Bike', 'Nova E-Bike', 'Super Eco', 'Other'] }, + { name: 'Single Rent - Economy', deposit: 15000, dailyRate: 250, weeklyRate: 1750, monthlyRate: 7500, contractMonths: [1, 3, 6, 12], evModels: ['Yadea G5', 'Yadea C1S', 'Himiwa 400', 'Himiwa 500', 'Himiwa 600', 'TVS iQube', 'Bexly 1S', 'Bexly 3S', 'Bexly 5E', 'Bolan E-Bike', 'Nova E-Bike', 'Super Eco', 'Other'] }, ], shared: [ - { name: 'Share an EV - Premium', deposit: 20000, dailyRate: 300, weeklyRate: 2100, monthlyRate: 8400, contractMonths: [1, 3, 6, 12] }, - { name: 'Share an EV - Standard', deposit: 15000, dailyRate: 200, weeklyRate: 1400, monthlyRate: 5600, contractMonths: [1, 3, 6, 12] }, - { name: 'Share an EV - Economy', deposit: 12000, dailyRate: 150, weeklyRate: 1050, monthlyRate: 4200, contractMonths: [1, 3, 6, 12] }, + { name: 'Share an EV - Premium', deposit: 20000, dailyRate: 300, weeklyRate: 2100, monthlyRate: 8400, contractMonths: [1, 3, 6, 12], evModels: ['Yadea G5', 'Yadea C1S', 'Himiwa 400', 'Himiwa 500', 'Himiwa 600', 'TVS iQube', 'Bexly 1S', 'Bexly 3S', 'Bexly 5E', 'Bolan E-Bike', 'Nova E-Bike', 'Super Eco', 'Other'] }, + { name: 'Share an EV - Standard', deposit: 15000, dailyRate: 200, weeklyRate: 1400, monthlyRate: 5600, contractMonths: [1, 3, 6, 12], evModels: ['Yadea G5', 'Yadea C1S', 'Himiwa 400', 'Himiwa 500', 'Himiwa 600', 'TVS iQube', 'Bexly 1S', 'Bexly 3S', 'Bexly 5E', 'Bolan E-Bike', 'Nova E-Bike', 'Super Eco', 'Other'] }, + { name: 'Share an EV - Economy', deposit: 12000, dailyRate: 150, weeklyRate: 1050, monthlyRate: 4200, contractMonths: [1, 3, 6, 12], evModels: ['Yadea G5', 'Yadea C1S', 'Himiwa 400', 'Himiwa 500', 'Himiwa 600', 'TVS iQube', 'Bexly 1S', 'Bexly 3S', 'Bexly 5E', 'Bolan E-Bike', 'Nova E-Bike', 'Super Eco', 'Other'] }, ], 'rent-to-own': [ - { name: 'Rent to Own - Premium', deposit: 25000, dailyRate: 350, weeklyRate: 2450, monthlyRate: 10500, contractMonths: [12, 18, 24, 36] }, - { name: 'Rent to Own - Standard', deposit: 18000, dailyRate: 250, weeklyRate: 1750, monthlyRate: 7000, contractMonths: [12, 18, 24, 36] }, - { name: 'Rent to Own - Economy', deposit: 15000, dailyRate: 200, weeklyRate: 1400, monthlyRate: 6000, contractMonths: [12, 18, 24, 36] }, + { name: 'Rent to Own - Premium', deposit: 25000, dailyRate: 350, weeklyRate: 2450, monthlyRate: 10500, contractMonths: [12, 18, 24, 36], evModels: ['Yadea G5', 'Yadea C1S', 'Himiwa 400', 'Himiwa 500', 'Himiwa 600', 'TVS iQube', 'Bexly 1S', 'Bexly 3S', 'Bexly 5E', 'Bolan E-Bike', 'Nova E-Bike', 'Super Eco', 'Other'] }, + { name: 'Rent to Own - Standard', deposit: 18000, dailyRate: 250, weeklyRate: 1750, monthlyRate: 7000, contractMonths: [12, 18, 24, 36], evModels: ['Yadea G5', 'Yadea C1S', 'Himiwa 400', 'Himiwa 500', 'Himiwa 600', 'TVS iQube', 'Bexly 1S', 'Bexly 3S', 'Bexly 5E', 'Bolan E-Bike', 'Nova E-Bike', 'Super Eco', 'Other'] }, + { name: 'Rent to Own - Economy', deposit: 15000, dailyRate: 200, weeklyRate: 1400, monthlyRate: 6000, contractMonths: [12, 18, 24, 36], evModels: ['Yadea G5', 'Yadea C1S', 'Himiwa 400', 'Himiwa 500', 'Himiwa 600', 'TVS iQube', 'Bexly 1S', 'Bexly 3S', 'Bexly 5E', 'Bolan E-Bike', 'Nova E-Bike', 'Super Eco', 'Other'] }, ], }); @@ -299,21 +299,25 @@ export default function RentalsPage() { userId: string; type: RentalType; planConditionName: string; + evModel: string; subscriptionType: 'daily' | 'weekly' | 'monthly'; contractMonths: number; bikeId: string; startDate: string; hubId: string; + depositAmount: number; depositPaymentMethod: PaymentMethod; }>({ userId: '', type: 'single', planConditionName: '', + evModel: '', subscriptionType: 'daily', contractMonths: 0, bikeId: '', startDate: new Date().toISOString().split('T')[0], hubId: '', + depositAmount: 0, depositPaymentMethod: 'cash', }); @@ -327,6 +331,8 @@ export default function RentalsPage() { setUnlockPermission(canRentalUnlock()); }, []); + + const getStatusBadge = (status: RentalStatus) => { const styles: Record = { active: 'bg-green-100 text-green-700', @@ -475,12 +481,14 @@ export default function RentalsPage() { setNewRental({ userId: '', type: 'single', -planConditionName: planConditions.single[1]?.name || '', + planConditionName: planConditions.single[1]?.name || '', subscriptionType: 'daily', contractMonths: 0, bikeId: '', + evModel: '', startDate: new Date().toISOString().split('T')[0], hubId: '', + depositAmount: 0, depositPaymentMethod: 'cash', }); }; @@ -694,7 +702,7 @@ planConditionName: planConditions.single[1]?.name || '',
-

Create New Rental - Step {createStep} of 5

+

Create New Rental - Step {createStep} of 4

@@ -750,7 +758,10 @@ planConditionName: planConditions.single[1]?.name || '',
+
+ + +
setNewRental({ ...newRental, startDate: e.target.value })} - className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" - /> -
-
- - -
-
- )} - - {createStep === 5 && ( -
-

Step 5: Deposit Payment

+

Step 4: Deposit Payment

Deposit Amount: ৳{selectedPlan?.deposit.toLocaleString()}

User: {selectedUser?.name}

Bike: {selectedBike?.model} ({selectedBike?.plate})

Hub: {mockHubs.find(h => h.id === newRental.hubId)?.name}

- {selectedPlan.deposit > 0 && ( +
+ {/*
+ + setNewRental({ ...newRental, depositAmount: Number(e.target.value) })} + className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm" + /> +
*/}
@@ -891,34 +897,49 @@ planConditionName: planConditions.single[1]?.name || '', ))}
- )} - {selectedPlan.deposit > 0 && ( -
-

Journal Preview

+
+ {newRental.depositAmount > 0 && ( +
+
+

Proforma Invoice

+
+
+
Invoice No:PI-{Date.now().toString().slice(-8)}
+
Date:{new Date().toLocaleDateString()}
+
Customer:{selectedUser?.name}
+
Bike:{selectedBike?.model} ({selectedBike?.plate})
+
- + - - - + + + - - + - - + + - - - - + + + + + + + + + + +
AccountDebitCreditDescriptionDebit (৳)Credit (৳)
+
{newRental.depositPaymentMethod === 'cash' && '1000 - Cash'} {newRental.depositPaymentMethod === 'bank' && '1100 - Bank'} {newRental.depositPaymentMethod === 'wallet' && '1200 - Biker Wallet'} ৳{selectedPlan.deposit}-{newRental.depositAmount.toLocaleString()}-
2100 - Deposit Received-৳{selectedPlan.deposit}
2100 - Deposit Received-{newRental.depositAmount.toLocaleString()}
Total{newRental.depositAmount.toLocaleString()}{newRental.depositAmount.toLocaleString()}
)} @@ -938,13 +959,12 @@ planConditionName: planConditions.single[1]?.name || '', )}
- {createStep < 5 ? ( + {createStep < 4 ? ( ) : ( <> - {selectedPlan.deposit > 0 && ( + {newRental.depositAmount > 0 && (