removed cron job that made rentals active. Now whether or not the rental is active is determined on the fly
This commit is contained in:
@@ -318,13 +318,16 @@ const Owning: React.FC = () => {
|
||||
};
|
||||
|
||||
// Filter owner rentals - exclude cancelled (shown in Rental History)
|
||||
// Use displayStatus for filtering/sorting as it includes computed "active" status
|
||||
const allOwnerRentals = ownerRentals
|
||||
.filter((r) => ["pending", "confirmed", "active"].includes(r.status))
|
||||
.filter((r) => ["pending", "confirmed", "active"].includes(r.displayStatus || r.status))
|
||||
.sort((a, b) => {
|
||||
const statusOrder = { pending: 0, confirmed: 1, active: 2 };
|
||||
const aStatus = a.displayStatus || a.status;
|
||||
const bStatus = b.displayStatus || b.status;
|
||||
return (
|
||||
statusOrder[a.status as keyof typeof statusOrder] -
|
||||
statusOrder[b.status as keyof typeof statusOrder]
|
||||
statusOrder[aStatus as keyof typeof statusOrder] -
|
||||
statusOrder[bStatus as keyof typeof statusOrder]
|
||||
);
|
||||
});
|
||||
|
||||
@@ -401,17 +404,17 @@ const Owning: React.FC = () => {
|
||||
<div className="mb-2">
|
||||
<span
|
||||
className={`badge ${
|
||||
rental.status === "active"
|
||||
(rental.displayStatus || rental.status) === "active"
|
||||
? "bg-success"
|
||||
: rental.status === "pending"
|
||||
: (rental.displayStatus || rental.status) === "pending"
|
||||
? "bg-warning"
|
||||
: rental.status === "confirmed"
|
||||
: (rental.displayStatus || rental.status) === "confirmed"
|
||||
? "bg-info"
|
||||
: "bg-danger"
|
||||
}`}
|
||||
>
|
||||
{rental.status.charAt(0).toUpperCase() +
|
||||
rental.status.slice(1)}
|
||||
{(rental.displayStatus || rental.status).charAt(0).toUpperCase() +
|
||||
(rental.displayStatus || rental.status).slice(1)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -512,7 +515,7 @@ const Owning: React.FC = () => {
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{rental.status === "confirmed" && (
|
||||
{(rental.displayStatus || rental.status) === "confirmed" && (
|
||||
<button
|
||||
className="btn btn-sm btn-outline-danger"
|
||||
onClick={() => handleCancelClick(rental)}
|
||||
@@ -520,7 +523,7 @@ const Owning: React.FC = () => {
|
||||
Cancel
|
||||
</button>
|
||||
)}
|
||||
{rental.status === "active" && (
|
||||
{(rental.displayStatus || rental.status) === "active" && (
|
||||
<button
|
||||
className="btn btn-sm btn-success"
|
||||
onClick={() => handleCompleteClick(rental)}
|
||||
|
||||
Reference in New Issue
Block a user