refactor mylistings and my rentals
This commit is contained in:
@@ -155,7 +155,7 @@ const Profile: React.FC = () => {
|
||||
);
|
||||
|
||||
// Fetch rentals where user is the owner (rentals on user's items)
|
||||
const ownerRentalsResponse = await rentalAPI.getMyListings();
|
||||
const ownerRentalsResponse = await rentalAPI.getListings();
|
||||
const ownerRentals: Rental[] = ownerRentalsResponse.data;
|
||||
|
||||
const acceptedRentals = ownerRentals.filter((r) =>
|
||||
@@ -194,14 +194,14 @@ const Profile: React.FC = () => {
|
||||
const fetchRentalHistory = async () => {
|
||||
try {
|
||||
// Fetch past rentals as a renter
|
||||
const renterResponse = await rentalAPI.getMyRentals();
|
||||
const renterResponse = await rentalAPI.getRentals();
|
||||
const pastRenterRentals = renterResponse.data.filter((r: Rental) =>
|
||||
["completed", "cancelled"].includes(r.status)
|
||||
);
|
||||
setPastRenterRentals(pastRenterRentals);
|
||||
|
||||
// Fetch past rentals as an owner
|
||||
const ownerResponse = await rentalAPI.getMyListings();
|
||||
const ownerResponse = await rentalAPI.getListings();
|
||||
const pastOwnerRentals = ownerResponse.data.filter((r: Rental) =>
|
||||
["completed", "cancelled"].includes(r.status)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user