feat(product-app): wire provider booking decline path (TEC-67)#25
Conversation
Co-Authored-By: Paperclip <noreply@paperclip.ing>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdds a provider booking decline flow: new decline lifecycle types and factories, updated provider screen UI/state to capture per-booking decline reasons and perform decline requests, strengthened decline request validation, and expanded tests and README to document the accept/decline routes. Changes
Sequence DiagramsequenceDiagram
actor User
participant Screen as Provider Screen
participant State as Provider State
participant API as Booking API
participant Network as Network Layer
User->>Screen: Tap "Decline" for booking
Screen->>Screen: Read decline reason from TextInput
Screen->>State: handleDecline(bookingId, declineReason)
State->>State: Set decliningId, clear mutationError
Screen->>API: declineBookingRequest(bookingId, {declineReason})
API->>Network: POST /bookings/{bookingId}/decline (Auth + JSON body)
Network-->>API: Response (success or error)
alt Success (status === 'declined')
API-->>State: Return declined booking
State->>Screen: Update declinedBooking, clear draft reason
Screen->>Screen: Remove booking from list, show decline confirmation
else Error or non-declined status
API-->>State: Return undefined / error
State->>Screen: Set mutationError, keep booking in list
end
User->>Screen: Tap "Reset"
Screen->>State: Clear confirmations and errors, reload bookings
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/product-app/src/features/provider/provider-state.ts (1)
131-146: Make the error helpers use the same argument order.
createErrorProviderScreenState(bookingId, errorMessage, declineReason?)andcreateDeclineErrorProviderScreenState(bookingId, declineReason, errorMessage)invert the string arguments. Because both trailing params arestring, a swapped call will compile and silently build the wrong state. Please align the signatures or move both helpers to a named-args object.♻️ One straightforward alignment
export const createDeclineErrorProviderScreenState = ( bookingId: string, - declineReason: string, errorMessage: string, + declineReason = '', ): ProviderScreenState => ({ status: 'idle', bookingId, acceptState: { status: 'idle', bookingId }, declineState: { status: 'error', bookingId, declineReason, errorMessage }, });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/product-app/src/features/provider/provider-state.ts` around lines 131 - 146, The two helpers have inverted trailing string params causing silent bugs; update createDeclineErrorProviderScreenState to match createErrorProviderScreenState's signature by accepting (bookingId: string, errorMessage: string, declineReason = '') and adjust the returned object so declineState: { status: 'error', bookingId, declineReason, errorMessage } (or alternatively switch both helpers to a single options object like { bookingId, errorMessage?, declineReason? }), and then update any call sites to the new parameter order.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@apps/product-app/src/features/booking/booking-screen-actions-decline.test.ts`:
- Around line 6-74: The test suite must cover and the implementation must
enforce that declineBookingRequest only treats responses with payload.status ===
'declined' as success; update the declineBookingRequest function to explicitly
check payload.status === 'declined' (not just a known status) before returning a
successful booking, and otherwise return an error result (e.g., set errorMessage
and no booking). Add a regression test in booking-screen-actions-decline.test.ts
that mocks the fetch returning { status: 'accepted', ... } and asserts that
declineBookingRequest returns an error (errorMessage present) and does not
return a booking, ensuring ProviderScreen cannot show a decline confirmation for
non-declined statuses.
In `@apps/product-app/src/features/provider/provider-screen.js`:
- Around line 19-24: The race happens because handlers read render-time state
(acceptingId/decliningId/isBusy) so a fast double-tap can dispatch both
handleAccept and handleDecline; fix by adding a synchronous guard using a ref
(e.g., pendingActionRef) that you set/read synchronously inside handleAccept and
handleDecline before calling acceptBookingRequest/declineBookingRequest, and
clear in the mutation callbacks (or finally). Update the button disable logic
(where it checks isBusy/acceptingId/decliningId) to also consider
pendingActionRef to prevent clicks before re-render, and keep existing
setAcceptingId/setDecliningId for UI state but rely on the ref for the true
mutex around non-idempotent mutations.
---
Nitpick comments:
In `@apps/product-app/src/features/provider/provider-state.ts`:
- Around line 131-146: The two helpers have inverted trailing string params
causing silent bugs; update createDeclineErrorProviderScreenState to match
createErrorProviderScreenState's signature by accepting (bookingId: string,
errorMessage: string, declineReason = '') and adjust the returned object so
declineState: { status: 'error', bookingId, declineReason, errorMessage } (or
alternatively switch both helpers to a single options object like { bookingId,
errorMessage?, declineReason? }), and then update any call sites to the new
parameter order.
🪄 Autofix (Beta)
✅ Autofix completed
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7dcb39ab-c7e0-4727-86b6-04aae2f8046f
📒 Files selected for processing (5)
README.mdapps/product-app/src/features/booking/booking-screen-actions-decline.test.tsapps/product-app/src/features/provider/provider-screen.jsapps/product-app/src/features/provider/provider-state.test.tsapps/product-app/src/features/provider/provider-state.ts
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Fixes Applied SuccessfullyFixed 3 file(s) based on 2 unresolved review comments. Files modified:
Commit: The changes have been pushed to the Time taken: |
Fixed 3 file(s) based on 2 unresolved review comments. Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
Summary
Validation
Summary by CodeRabbit
New Features
Tests
Documentation