Skip to content

[PTF] Add post transaction flow networking#90

Merged
conniecliu merged 2 commits intomainfrom
Connie/PTFNetworking
Mar 2, 2026
Merged

[PTF] Add post transaction flow networking#90
conniecliu merged 2 commits intomainfrom
Connie/PTFNetworking

Conversation

@conniecliu
Copy link
Contributor

@conniecliu conniecliu commented Feb 22, 2026

Overview

Added networking between PTF UI and backend. This PR includes a fully networked transaction completed chat navigation, Post Transaction Review Screen, transaction review submission, and feedback submission.

Changes Made

  • Added repositories and API services for Transaction, TransactionReview, and Feedback
  • Implemented transaction completion check so that the "view transaction" banner only appears in the chat screen if a transaction is completed
  • Removed dummy logic from earlier PRs

Test Coverage

  • Marked a transaction as completed in the dev server and manually added the ID to the corresponding chat document in Firestore.
  • Checked if this was being reflected in the UI
  • Android Studio Emulator and logging to double-check transaction reviews and feedback submissions were going through

Next Steps

  • Debug as necessary

Related PRs or Issues

Past UI PRs:

Screenshots (delete if not applicable)

Screen Shot Name
screen-20260222-184737-1771804027748.1.1.mp4

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds networking functionality to the Post Transaction Flow (PTF) feature in the Resell Android app. It connects the previously implemented UI components (from PRs #83 and #86) with the backend API to enable users to submit transaction reviews and feedback after completing a purchase.

Changes:

  • Added API services and repositories for transactions, transaction reviews, and feedback
  • Implemented transaction completion checking in chat screens to display "Leave Review" banners when applicable
  • Connected the transaction rating and feedback submission flows to the backend

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
app/src/main/java/com/cornellappdev/resell/android/model/api/TransactionApiService.kt New API service for transaction-related endpoints
app/src/main/java/com/cornellappdev/resell/android/model/api/TransactionReviewApiService.kt New API service for transaction review endpoints
app/src/main/java/com/cornellappdev/resell/android/model/api/FeedbackApiService.kt New API service for feedback submission
app/src/main/java/com/cornellappdev/resell/android/model/ptf/PostTransactionRatingRepository.kt Repository for transaction and review operations
app/src/main/java/com/cornellappdev/resell/android/model/ptf/FeedbackRepository.kt Repository for feedback operations
app/src/main/java/com/cornellappdev/resell/android/viewmodel/main/PostTransactionRatingViewModel.kt Added networking to load transaction data and submit reviews
app/src/main/java/com/cornellappdev/resell/android/viewmodel/main/ChatViewModel.kt Added transaction completion check to show PTF banner
app/src/main/java/com/cornellappdev/resell/android/viewmodel/feedback/FeedbackDetailsViewModel.kt Added networking for feedback submission
app/src/main/java/com/cornellappdev/resell/android/ui/screens/main/PostTransactionRatingScreen.kt Updated to use real transaction data from API
app/src/main/java/com/cornellappdev/resell/android/ui/screens/main/ChatScreen.kt Added transaction state UI when transaction is completed
app/src/main/java/com/cornellappdev/resell/android/ui/components/chat/ChatTransactionState.kt New component for displaying transaction state in chat
app/src/main/java/com/cornellappdev/resell/android/ui/components/chat/ChatMessageCluster.kt Updated to handle transaction state messages
app/src/main/java/com/cornellappdev/resell/android/ui/components/chat/ResellChatScroll.kt Added transaction state click handler
app/src/main/java/com/cornellappdev/resell/android/model/chats/ChatDocument.kt Added transactionId field and TransactionInfo data class
app/src/main/java/com/cornellappdev/resell/android/model/Chat.kt Added transactionInfo and transactionId fields to ChatMessageData
app/src/main/java/com/cornellappdev/resell/android/model/api/ChatRepository.kt Updated to handle transactionId in chat messages
app/src/main/java/com/cornellappdev/resell/android/model/login/FireStoreRepository.kt Updated to include transactionId when parsing Firestore messages
app/src/main/java/com/cornellappdev/resell/android/model/api/RetrofitInstance.kt Added lazy initialization for new API services
app/src/main/res/drawable/ic_bag.xml New icon for transaction state indicator
Comments suppressed due to low confidence (6)

app/src/main/java/com/cornellappdev/resell/android/model/api/FeedbackApiService.kt:10

  • Incorrect parameter name in searchFeedback endpoint. The function parameter is named reportBody but should be named searchBody or feedbackBody to match the actual data type being used (SearchFeedback, not FeedbackBody). This is misleading and inconsistent with the naming in createFeedback where the parameter correctly matches the type.
    suspend fun searchFeedback(@Body reportBody : SearchFeedback): SearchFeedback

app/src/main/java/com/cornellappdev/resell/android/viewmodel/main/ChatViewModel.kt:705

  • Unusual spacing in safe call operator. There's a space between ?. on line 705, which should be ?. without the space. This is inconsistent with standard Kotlin formatting conventions.
                        ?. transactionId

app/src/main/java/com/cornellappdev/resell/android/viewmodel/main/PostTransactionRatingViewModel.kt:130

  • Typo in log message: "subtmiting" should be "submitting"
                Log.e("PostTransactionRatingViewModel", "Error subtmiting review.", e)

app/src/main/java/com/cornellappdev/resell/android/ui/screens/main/PostTransactionRatingScreen.kt:133

  • The elvis operator (?:) on line 133 is unnecessary since date is now non-nullable (changed from Date? to Date in the function parameter). The ?.let is also unnecessary. This should be simplified to just SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault()).format(date).
    val formattedDate = remember(date) {
        date.let { SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault()).format(it) } ?: "Month 00, 0000"

app/src/main/java/com/cornellappdev/resell/android/model/ptf/PostTransactionRatingRepository.kt:17

  • The methods getTransactionDetails and getTransactionById are duplicates - they both call the same API endpoint and return the same data. The getTransactionDetails method (lines 15-17) is redundant and should be removed. Only getTransactionById should be kept.
    suspend fun getTransactionDetails(transactionId: String): Transaction {
        return retrofitInstance.transactionApi.getTransactionById(transactionId).transaction
    }

app/src/main/java/com/cornellappdev/resell/android/model/api/TransactionApiService.kt:11

  • Inconsistent trailing slash in API endpoint path. The endpoint is defined as "transaction/id/{id}" without a trailing slash, while getTransactionByPostId uses "transaction/postId/{id}/" with a trailing slash. For consistency with the other endpoint in this file and to follow the pattern seen in TransactionReviewApiService, this should either have a trailing slash on both or neither.
    @GET("transaction/id/{id}")
    suspend fun getTransactionById(@Path("id") id : String) : TransactionResponse

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +59 to +60
val transactionFromPostId = postTransactionRatingRepository.getTransactionByPostId(navArgs.postId)
val transaction = postTransactionRatingRepository.getTransactionById(transactionFromPostId.id)
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

Two sequential API calls when one would suffice. The code first calls getTransactionByPostId to get a transaction, then immediately calls getTransactionById with the returned transaction's ID. This results in two network requests when only one is needed. The getTransactionByPostId already returns the complete Transaction object, so the second call to getTransactionById is redundant. Consider removing line 60 and using transactionFromPostId directly instead of calling getTransactionById.

Suggested change
val transactionFromPostId = postTransactionRatingRepository.getTransactionByPostId(navArgs.postId)
val transaction = postTransactionRatingRepository.getTransactionById(transactionFromPostId.id)
val transaction = postTransactionRatingRepository.getTransactionByPostId(navArgs.postId)

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

^^ This seems to make sense to fix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh I did that because in the backend when we fetch a transaction with a post ID, we aren't able to get information about the seller and buyer (the former we need to display the seller's information on the screen): https://github.com/cuappdev/resell-backend/blob/main/src/repositories/TransactionRepository.ts

@conniecliu conniecliu requested a review from caleb-bit February 23, 2026 03:17
@AndrewCheung360
Copy link
Member

In the recording, a dialog UI shows up that says "failed to submit review, try again later". Does that mean the submission failed or is it just because it is the dev server?

.create(SettingsApiService::class.java)
}

val transactionApi: TransactionApiService by lazy {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: This is technically fine and can be ignored for this pr since that was how it was for the previous api services, but for future refactors, there seems to be a lot of repeated code between the apiservices aside from the .create(...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeahh for sure, I agree. Maybe we can refactor it out

else -> R.drawable.ic_bag
}

fun convertToUtcMinusFiveDate(): Date {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: This logic seems to be repeated, so we could probably make some sort of reusable function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Realized the function was never called so I removed it

messageType = MessageType.State,
content = "This transaction has been completed",
transactionInfo = TransactionInfo(
completeTime = Timestamp(Date()),
Copy link
Member

Choose a reason for hiding this comment

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

Should we be getting the timestamp of the actual completion of the transaction from the vm or is this just a placeholder or something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a mistake on my part, we should be getting the completion date from the vm! Fixed.

@conniecliu
Copy link
Contributor Author

In the recording, a dialog UI shows up that says "failed to submit review, try again later". Does that mean the submission failed or is it just because it is the dev server?

Each listing should only be allowed to have one transaction review submitted per user, so the dialog UI that shows up is because I had already created a transaction review for that listing. Though, instead of "failed to submit review, try again letter" it should really show something along the lines of "transaction review already submitted!" I'll go ahead and implement that.

Copy link
Member

@AndrewCheung360 AndrewCheung360 left a comment

Choose a reason for hiding this comment

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

LGTM

@conniecliu conniecliu merged commit 09f546e into main Mar 2, 2026
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.

3 participants