diff --git a/src/app/admin/rentals/page.tsx b/src/app/admin/rentals/page.tsx index efcc6db..e3fcf58 100644 --- a/src/app/admin/rentals/page.tsx +++ b/src/app/admin/rentals/page.tsx @@ -104,9 +104,21 @@ const mockHubs = [ ]; const rentalSettings = { - single: { deposit: 3000, contractMonths: [1, 3, 6, 12], dailyRate: 150, weeklyRate: 900, monthlyRate: 3500 }, - shared: { deposit: 2000, contractMonths: [1, 3, 6], dailyRate: 100, weeklyRate: 600, monthlyRate: 2200 }, - 'rent-to-own': { deposit: 10000, contractMonths: [12, 18, 24, 36], dailyRate: 500, weeklyRate: 3000, monthlyRate: 12000 }, + single: { + Premium: { deposit: 5000, contractMonths: [1, 3, 6, 12], dailyRate: 200, weeklyRate: 1200, monthlyRate: 5000 }, + Standard: { deposit: 3000, contractMonths: [1, 3, 6, 12], dailyRate: 150, weeklyRate: 900, monthlyRate: 3500 }, + Economy: { deposit: 2000, contractMonths: [1, 3, 6, 12], dailyRate: 100, weeklyRate: 600, monthlyRate: 2500 }, + }, + shared: { + Premium: { deposit: 4000, contractMonths: [1, 3, 6], dailyRate: 150, weeklyRate: 900, monthlyRate: 3500 }, + Standard: { deposit: 2500, contractMonths: [1, 3, 6], dailyRate: 100, weeklyRate: 600, monthlyRate: 2200 }, + Economy: { deposit: 2000, contractMonths: [1, 3, 6], dailyRate: 80, weeklyRate: 500, monthlyRate: 1800 }, + }, + 'rent-to-own': { + Premium: { deposit: 15000, contractMonths: [12, 18, 24, 36], dailyRate: 350, weeklyRate: 2450, monthlyRate: 10500 }, + Standard: { deposit: 12000, contractMonths: [12, 18, 24, 36], dailyRate: 250, weeklyRate: 1750, monthlyRate: 7000 }, + Economy: { deposit: 10000, contractMonths: [12, 18, 24, 36], dailyRate: 200, weeklyRate: 1400, monthlyRate: 6000 }, + }, }; const mockRentals: Rental[] = [ @@ -265,6 +277,7 @@ export default function RentalsPage() { const [newRental, setNewRental] = useState<{ userId: string; type: RentalType; + condition: 'Premium' | 'Standard' | 'Economy'; subscriptionType: 'daily' | 'weekly' | 'monthly'; contractMonths: number; bikeId: string; @@ -274,6 +287,7 @@ export default function RentalsPage() { }>({ userId: '', type: 'single', + condition: 'Standard', subscriptionType: 'daily', contractMonths: 0, bikeId: '', @@ -379,6 +393,8 @@ export default function RentalsPage() { const eligibleUsers = mockUsers.filter(u => u.kycStatus === 'approved' && !u.hasActiveRental); const availableBikes = mockBikes.filter(b => b.status === 'available'); + const selectedSettings = rentalSettings[newRental.type]?.[newRental.condition] || rentalSettings.single.Standard; + const stats = { active: rentals.filter(r => r.status === 'active').length, pending: rentals.filter(r => r.status === 'pending').length, @@ -395,7 +411,7 @@ export default function RentalsPage() { const bike = mockBikes.find(b => b.id === newRental.bikeId); const user = mockUsers.find(u => u.id === newRental.userId); const hub = mockHubs.find(h => h.id === newRental.hubId); - const settings = rentalSettings[newRental.type]; + const settings = rentalSettings[newRental.type]?.[newRental.condition]; const rental: Rental = { id: `RNT-${String(rentals.length + 1).padStart(3, '0')}`, @@ -438,6 +454,7 @@ export default function RentalsPage() { setNewRental({ userId: '', type: 'single', + condition: 'Standard', subscriptionType: 'daily', contractMonths: 0, bikeId: '', @@ -447,7 +464,6 @@ export default function RentalsPage() { }); }; - const selectedSettings = rentalSettings[newRental.type]; const selectedBike = mockBikes.find(b => b.id === newRental.bikeId); const selectedUser = mockUsers.find(u => u.id === newRental.userId); @@ -683,12 +699,11 @@ export default function RentalsPage() { {createStep === 2 && (
+ End Date: {new Date(new Date(newRental.startDate).setMonth(new Date(newRental.startDate).getMonth() + newRental.contractMonths)).toISOString().split('T')[0]} +
+ )}Deposit: ৳{selectedSettings.deposit.toLocaleString()}
+Deposit: ৳{selectedSettings.deposit.toLocaleString()}
- Rate: ৳{newRental.subscriptionType === 'daily' ? selectedSettings.dailyRate : newRental.subscriptionType === 'weekly' ? selectedSettings.weeklyRate : selectedSettings.monthlyRate}/ - {newRental.subscriptionType === 'daily' ? 'day' : newRental.subscriptionType === 'weekly' ? 'week' : 'month'} + Rate: ৳{newRental.subscriptionType === 'daily' ? selectedSettings.dailyRate : newRental.subscriptionType === 'weekly' ? selectedSettings.weeklyRate : selectedSettings.monthlyRate} + /{newRental.subscriptionType === 'daily' ? 'day' : newRental.subscriptionType === 'weekly' ? 'week' : 'month'}