diff --git a/src/app/admin/rentals/page.tsx b/src/app/admin/rentals/page.tsx
index 2b53247..7d2bf5a 100644
--- a/src/app/admin/rentals/page.tsx
+++ b/src/app/admin/rentals/page.tsx
@@ -171,6 +171,7 @@ const mockRentals: Rental[] = [
dailyRate: 150,
weeklyRate: 900,
monthlyRate: 3500,
+ batteryRent: 1500,
totalPaid: 38500,
dueRental: 0,
pendingRent: 0,
@@ -272,6 +273,7 @@ const mockRentals: Rental[] = [
dailyRate: 100,
weeklyRate: 600,
monthlyRate: 2200,
+ batteryRent: 1500,
totalPaid: 2600,
dueRental: 600,
pendingRent: 600,
@@ -692,23 +694,42 @@ export default function RentalsPage() {
*/}
{(() => {
- const rent = rental[rental.subscriptionType === 'daily' ? 'dailyRate' : rental.subscriptionType === 'weekly' ? 'weeklyRate' : 'monthlyRate'];
- const due = rental.pendingRent || 0;
+ const bikeRent = rental[rental.subscriptionType === 'daily' ? 'dailyRate' : rental.subscriptionType === 'weekly' ? 'weeklyRate' : 'monthlyRate'];
+ const batteryRent = rental.batteryRent || 0;
+ const batteryRentAdjusted = rental.subscriptionType === 'daily'
+ ? Math.round(batteryRent / 30)
+ : rental.subscriptionType === 'weekly'
+ ? Math.round(batteryRent / 4)
+ : batteryRent;
+ const totalRent = bikeRent + batteryRentAdjusted;
+ const due = rental.pendingRent + rental.batteryRentPending || 0;
const penalty = rental.penaltyAmount || 0;
const totalDue = due + penalty;
+ const periodLabel = rental.subscriptionType === 'daily' ? 'day' : rental.subscriptionType === 'weekly' ? 'wk' : 'mo';
if (totalDue > 0) {
return (
-
+
৳{totalDue.toLocaleString()}
- {rental.subscriptionType} ৳{rent}/{(rental.subscriptionType === 'daily' ? 'day' : rental.subscriptionType === 'weekly' ? 'wk' : 'mo')}
- {penalty > 0 && +৳{penalty} penalty}
+ {batteryRent > 0 ? (
+
+ {rental.subscriptionType} ৳{bikeRent}{periodLabel} +Battery: ৳{batteryRentAdjusted}{periodLabel}
+
+ ) : (
+ {rental.subscriptionType} ৳{totalRent}{periodLabel} +৳{penalty} penalty
+ )}
);
}
return (
-
- ৳{rent.toLocaleString()}
- {rental.subscriptionType}
+
+ ৳{totalRent.toLocaleString()}
+ {batteryRent > 0 ? (
+
+ {rental.subscriptionType} ৳{bikeRent}{periodLabel} +Battery: ৳{batteryRentAdjusted}{periodLabel}
+
+ ) : (
+ {rental.subscriptionType}
+ )}
);
})()}
@@ -800,18 +821,39 @@ export default function RentalsPage() {
{rental.depositPaid ? 'Paid' : 'Unpaid'}
- {totalDue > 0 ? (
-
- ৳{totalDue.toLocaleString()}
- {rental.subscriptionType} ৳{rent}/{(rental.subscriptionType === 'daily' ? 'day' : rental.subscriptionType === 'weekly' ? 'wk' : 'mo')}
- {penalty > 0 && +৳{penalty}}
-
- ) : (
-
- ৳{rent.toLocaleString()}
- {rental.subscriptionType}
-
- )}
+ {(() => {
+ const batteryRent = rental.batteryRent || 0;
+ const batteryRentAdjusted = rental.subscriptionType === 'daily'
+ ? Math.round(batteryRent / 30)
+ : rental.subscriptionType === 'weekly'
+ ? Math.round(batteryRent / 4)
+ : batteryRent;
+ const totalRent = rent + batteryRentAdjusted;
+ const periodLabel = rental.subscriptionType === 'daily' ? 'day' : rental.subscriptionType === 'weekly' ? 'wk' : 'mo';
+ return totalDue > 0 ? (
+
+ ৳{totalDue.toLocaleString()}
+ {batteryRent > 0 ? (
+
+ {rental.subscriptionType} ৳{rent}{periodLabel} +Battery: ৳{batteryRentAdjusted}{periodLabel} +৳{penalty} penalty
+
+ ) : (
+ {rental.subscriptionType} ৳{totalRent}{periodLabel} +৳{penalty} penalty
+ )}
+
+ ) : (
+
+ ৳{totalRent.toLocaleString()}
+ {batteryRent > 0 ? (
+
+ {rental.subscriptionType} ৳{rent}{periodLabel} +Battery: ৳{batteryRentAdjusted}{periodLabel}
+
+ ) : (
+ {rental.subscriptionType}
+ )}
+
+ );
+ })()}
@@ -967,10 +1009,21 @@ export default function RentalsPage() {
{newRental.planConditionName}
Deposit: ৳{selectedPlan?.deposit.toLocaleString()}
-
- Rate: ৳{newRental.subscriptionType === 'daily' ? selectedPlan?.dailyRate : newRental.subscriptionType === 'weekly' ? selectedPlan?.weeklyRate : selectedPlan?.monthlyRate}
- /{newRental.subscriptionType === 'daily' ? 'day' : newRental.subscriptionType === 'weekly' ? 'week' : 'month'}
-
+
+ Rate:
+ {(() => {
+ const bikeRate = newRental.subscriptionType === 'daily' ? selectedPlan?.dailyRate : newRental.subscriptionType === 'weekly' ? selectedPlan?.weeklyRate : selectedPlan?.monthlyRate;
+ const batteryRent = newRental.batteryRent || 0;
+ const batteryRate = batteryRent > 0 ? (newRental.subscriptionType === 'daily' ? Math.round(batteryRent / 30) : newRental.subscriptionType === 'weekly' ? Math.round(batteryRent / 4) : batteryRent) : 0;
+ const totalRate = bikeRate + batteryRate;
+ return (
+
+ ৳{totalRate.toLocaleString()}/{newRental.subscriptionType === 'daily' ? 'day' : newRental.subscriptionType === 'weekly' ? 'week' : 'month'}
+ {batteryRent > 0 && (Bike: ৳{bikeRate} + Battery: ৳{batteryRate})}
+
+ );
+ })()}
+
)}
@@ -978,7 +1031,7 @@ export default function RentalsPage() {
{createStep === 3 && (
Step 3: Select Bike & Battery
-
+
|