Skip to content

feat(booking): added my bookings - #383

Merged
adrimikh merged 3 commits into
mainfrom
feature/cancel-booking-wirevm
Nov 18, 2026
Merged

adrimikh merged 3 commits into
mainfrom
feature/cancel-booking-wirevm

Conversation

@adrimikh

Copy link
Copy Markdown
Contributor

Summary

Closes #361 and #362. Adds renter ("My bookings") and lender ("Booking requests") screens wired to BookingViewModel, showing loading, cancellation and error states, with entry points from Profile and the owner's listing detail.

What

  • BookingViewModel: loadListingBookings(listingId) for the lender, sharing one load path with loadRenterBookings.
  • New BookingListScreens.kt: RenterBookingsScreen, LenderBookingsScreen and BookingListContent, with an IDE preview. They show a loading spinner, an error banner with Retry, an empty state and a "Cancelling…" row state. A cancelled booking stays listed as cancelled, and a cancellation the server rejects is shown with the restored status and an error.
  • Navigation: routes renter_bookings and lender_bookings/{listingId} in Routes and AppNavHost.
  • Entry points: a "My bookings" button on Profile, and a "Booking requests" button in the owner's booking bar on the listing detail.
  • Strings for the new screens; FakeBookingRepository now supports listing bookings.
  • Tests: loadListingBookings ViewModel test and BookingListScreensTest (7 Compose tests for cancel, cancelling, cancelled, loading, error, and offline rejection).

Why

Cancellation and loading existed in the ViewModel and repository but had no screen, so users could not see or cancel their bookings. Offline cancellations that the server rejects later must be visible to the user, not silently reverted.

Validation

  • ./gradlew testDebugUnitTest --tests '*BookingListScreensTest' --tests '*BookingViewModelTest': passed (7 and 19 tests, 0 failures).
  • ./gradlew compileDebugKotlin: passed.
  • ./gradlew ktfmtFormat run.

Follow-ups

  • Lender screen has no listing title and shows no renter name; the data model has only uids (no issue yet).
  • Lender-side accept/confirm of requests is not included (no issue yet).

AI use

Copilot wrote code. I reviewed it and tested it.

@adrimikh
adrimikh requested a review from peng-0110 November 18, 2026 17:03
peng-0110
peng-0110 previously approved these changes Nov 18, 2026

@peng-0110 peng-0110 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work. Just a few things I noticed while reviewing the PR.

Must fix

  1. CI no longer compiles. The build now fails before any test runs: AppNavHostTest.kt:1074: Unresolved reference 'onAllNodesWithTag'. It's a missing import: import androidx.compose.ui.test.onAllNodesWithTag.
  2. The new retry test will likely fail once it compiles (BookingListScreensTest.kt, lenderBookingsScreen_retriesLoadAndCancelsBooking). It clicks Retry first and only then clears repository.loadFailure. The ViewModel probably starts the reload on the click itself, so the reload fails again and waitUntil times out. Clearing loadFailure = null before performClick() fixes it. I haven't run it, but the order is wrong either way.
  3. Finished bookings can be cancelled. Cancel shows on every booking that isn't already cancelled, and the rules accept it. A completed rental can be rewritten as cancelled, which corrupts the lender's history. Hide Cancel when all of a booking's days are before today, and ideally refuse it in the rules too.
  4. Lenders can't tell requests apart. Rows show only the dates and the status. A lender with two requests can't know which renter's booking they're cancelling. Showing the renter's name on the lender screen, and the listing title on "My bookings", fixes this.

Can fix (cheap)
5. Sort bookings by date. Right now they come back in Firestore document-ID order, which is effectively random.
6. Retry after a refused cancel only reloads the list. It doesn't retry the cancel. Either retry the cancel, or show a plain dismissable error for cancel failures.

@peng-0110
peng-0110 dismissed their stale review November 18, 2026 17:37

Meant to select Changes Required

@peng-0110 peng-0110 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meant to Request Changes in previous Review

@sonarqubecloud

Copy link
Copy Markdown

@peng-0110 peng-0110 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adrimikh
adrimikh merged commit fa0b157 into main Nov 18, 2026
4 checks passed
@adrimikh
adrimikh deleted the feature/cancel-booking-wirevm branch November 18, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wire renter and lender booking screens to the ViewModel; show loading, cancellation, and error states.

2 participants