Repository navigation
feat(listing): show status for every listing in toolbox #387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+608
−37
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b4e7904
feat(booking): list the bookings of all of a lender's listings
peng-0110 a7286ae
feat(toolbox): show whether each listing is available or booked today
peng-0110 49e1cdf
fix(toolbox): show no status after a failed bookings refresh
peng-0110 9d1f182
Merge remote-tracking branch 'origin/main' into feature/toolbox-listi…
peng-0110 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
app/src/main/java/com/android/polybazaar/toolbox/model/ToolboxListingStatus.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package com.android.polybazaar.toolbox.model | ||
|
|
||
| import com.android.polybazaar.booking.model.Booking | ||
| import com.android.polybazaar.booking.model.BookingStatus | ||
| import com.android.polybazaar.listing.model.Listing | ||
| import java.time.LocalDate | ||
|
|
||
| /** | ||
| * What the owner's Toolbox says about one of their listings (#196), derived from the listing and | ||
| * its bookings rather than stored. | ||
| * | ||
| * Lenders cannot approve or reject a request yet, so any booking that is not cancelled and covers | ||
| * today makes the listing [BookedToday]. Once requests can be approved, it should only count | ||
| * approved bookings. Bookings on later days do not show: the listing is still [Available] today. | ||
| */ | ||
| sealed interface ToolboxListingStatus { | ||
| /** Hidden from everyone else by its owner; shown whatever its bookings. */ | ||
| data object Paused : ToolboxListingStatus | ||
|
|
||
| /** A booking that is not cancelled covers today. */ | ||
| data object BookedToday : ToolboxListingStatus | ||
|
|
||
| /** Not paused, and no booking that is not cancelled covers today. */ | ||
| data object Available : ToolboxListingStatus | ||
| } | ||
|
|
||
| /** | ||
| * The status of [listing] on [today], from [bookings], which may include those of other listings. | ||
| */ | ||
| fun toolboxListingStatus( | ||
| listing: Listing, | ||
| bookings: List<Booking>, | ||
| today: LocalDate, | ||
| ): ToolboxListingStatus { | ||
| if (listing.isPaused) return ToolboxListingStatus.Paused | ||
| val bookedToday = bookings.any { | ||
| it.listingId == listing.listingId && it.status != BookingStatus.CANCELLED && today in it.days | ||
| } | ||
| return if (bookedToday) ToolboxListingStatus.BookedToday else ToolboxListingStatus.Available | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.