Skip to content

feat(product-app): wire provider booking decline path (TEC-67)#25

Merged
imKXNNY merged 2 commits into
mainfrom
feature/tec-67-provider-decline
Apr 15, 2026
Merged

feat(product-app): wire provider booking decline path (TEC-67)#25
imKXNNY merged 2 commits into
mainfrom
feature/tec-67-provider-decline

Conversation

@imKXNNY

@imKXNNY imKXNNY commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • wire provider-side booking decline flow with optional reason on provider screen
  • add provider state helpers/tests for decline lifecycle and error handling
  • extend decline action tests and README flow notes

Validation

  • corepack pnpm --filter @quickwerk/product-app test -- apps/product-app/src/features/provider/provider-state.test.ts apps/product-app/src/features/booking/booking-screen-actions-decline.test.ts

Summary by CodeRabbit

  • New Features

    • Providers can decline bookings with optional multiline decline reasons; per-booking Accept and Decline buttons and confirmation feedback added. Inputs and buttons are disabled while an action is in-flight.
  • Tests

    • Expanded tests for decline flows, success/error cases, and stronger request assertions.
  • Documentation

    • README updated to list the provider booking accept/decline flow.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c6ae7d15-4783-4d9e-bace-a34c80bd4d3f

📥 Commits

Reviewing files that changed from the base of the PR and between e42f279 and 35a8366.

📒 Files selected for processing (3)
  • apps/product-app/src/features/booking/booking-screen-actions-decline.test.ts
  • apps/product-app/src/features/booking/booking-screen-actions.ts
  • apps/product-app/src/features/provider/provider-screen.js
✅ Files skipped from review due to trivial changes (1)
  • apps/product-app/src/features/provider/provider-screen.js

📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
Documentation
README.md
Updated "Product app" section to list the implemented provider booking accept/decline flow and adjusted wording to reference "booking accept/decline transitions."
Booking decline request & tests
apps/product-app/src/features/booking/booking-screen-actions.ts, apps/product-app/src/features/booking/booking-screen-actions-decline.test.ts
declineBookingRequest now requires payload.status === 'declined'. Tests replaced shared mock helper with per-test fetchMock implementations, assert endpoint /bookings/{id}/decline, POST method, auth/content-type headers, body payload (including omitted declineReason case), and cover error/regression scenarios.
Provider state types & factories
apps/product-app/src/features/provider/provider-state.ts, apps/product-app/src/features/provider/provider-state.test.ts
Added exported DeclineBookingState union and extended ProviderScreenState to include declineState. Updated existing factory signatures to accept declineReason and added decline-specific factories (createDecliningProviderScreenState, createDeclinedProviderScreenState, createDeclineErrorProviderScreenState). Tests expanded for decline-state scenarios.
Provider screen UI & logic
apps/product-app/src/features/provider/provider-screen.js
Implemented decline flow: per-booking TextInput for optional decline reason, declineBookingRequest integration, decliningId/bookingDraftReasons/mutationError/declinedBooking state, handleDecline and shared mutation guarding (pendingActionRef), accept/decline buttons per booking, updated confirmations and reset behavior.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I nibbled on code by soft moonbeam light,

Decline reasons tucked in each booking's sight,
Buttons placed gentle, tests snug and bright,
State hopped along, mutations kept polite,
Now provider flows dance — tidy, swift, and right.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: wiring the provider booking decline path, with ticket reference TEC-67.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/tec-67-provider-decline

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

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?) and createDeclineErrorProviderScreenState(bookingId, declineReason, errorMessage) invert the string arguments. Because both trailing params are string, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1b6190d and e42f279.

📒 Files selected for processing (5)
  • README.md
  • apps/product-app/src/features/booking/booking-screen-actions-decline.test.ts
  • apps/product-app/src/features/provider/provider-screen.js
  • apps/product-app/src/features/provider/provider-state.test.ts
  • apps/product-app/src/features/provider/provider-state.ts

Comment thread apps/product-app/src/features/provider/provider-screen.js
@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 3 file(s) based on 2 unresolved review comments.

Files modified:

  • apps/product-app/src/features/booking/booking-screen-actions-decline.test.ts
  • apps/product-app/src/features/booking/booking-screen-actions.ts
  • apps/product-app/src/features/provider/provider-screen.js

Commit: 35a8366e2d9fbab3400870bdc9a45d1e09933aa2

The changes have been pushed to the feature/tec-67-provider-decline branch.

Time taken: 7m 41s

Fixed 3 file(s) based on 2 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
@imKXNNY imKXNNY merged commit 77767aa into main Apr 15, 2026
2 checks passed
@imKXNNY imKXNNY deleted the feature/tec-67-provider-decline branch April 15, 2026 11:54
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.

1 participant