Skip to content

fix: send real decline request in Vouch page - #93

Open
prissca wants to merge 1 commit into
StepFi-app:mainfrom
prissca:fix/issue-66-decline-vouch
Open

fix: send real decline request in Vouch page#93
prissca wants to merge 1 commit into
StepFi-app:mainfrom
prissca:fix/issue-66-decline-vouch

Conversation

@prissca

@prissca prissca commented Jul 27, 2026

Copy link
Copy Markdown

Summary

handleDecline used setTimeout(() => r(), 600) to fake declining a vouch request — no API call was made, so the request reappeared on refresh.

The backend previously had no decline endpoint at all — the issue's premise ("the endpoint exists but isn't wired") turned out to be inaccurate. See the companion StepFi-API PR (StepFi-app/StepFi-API#109) adding POST /vouching/decline. This PR depends on that one.

  • vouching.service.ts: added declineVouch(learnerAddress), matching the existing submitVouch/revokeVouch call shape.
  • useOptimisticVouch.ts: added useDeclineVouch(), mirroring useRevokeVouch's optimistic-update/rollback pattern.
  • Vouch.tsx: handleDecline now calls declineMutation.mutate instead of faking a delay. The existing declining/loading prop on VouchRequestCard (already wired to show a spinner) now reflects a real in-flight request, and a failure surfaces via the existing toast error pattern.
  • Extended optimisticMutations.test.ts with useDeclineVouch coverage (optimistic removal + persistence on success, rollback on failure).

Depends on: StepFi-app/StepFi-API#109

Closes #66

Test plan

  • Could not run vitest locally — node_modules here has a broken/incomplete native optional dependency (@rolldown/binding-win32-x64-msvc missing) unrelated to this change; please run npm test after npm i
  • Manually decline a pending vouch request, confirm the spinner shows during the request, the request disappears, and it does NOT reappear after a page refresh
  • Manually simulate a failed decline (e.g. offline) and confirm the request reappears with an error toast

handleDecline used setTimeout(() => r(), 600) to fake declining a vouch
request — no API call was made, so the request reappeared on refresh.

The backend previously had no decline endpoint at all (the issue's
"the endpoint exists but isn't wired" premise was inaccurate — see the
companion StepFi-API PR adding POST /vouching/decline). With that now
in place:

- vouching.service.ts: added declineVouch(learnerAddress), matching the
  existing submitVouch/revokeVouch call shape (POST /vouching/decline).
- useOptimisticVouch.ts: added useDeclineVouch(), mirroring
  useRevokeVouch's optimistic-update/rollback pattern — the declined
  request is optimistically removed from the requests cache and
  restored on error.
- Vouch.tsx: handleDecline now calls declineMutation.mutate instead of
  faking a delay; the existing declining/loading prop on
  VouchRequestCard (already wired to show a spinner) now reflects a
  real in-flight request, and a failure surfaces via the existing toast
  error pattern.
- Extended optimisticMutations.test.ts with useDeclineVouch coverage
  (optimistic removal + persistence on success, rollback on failure).

Depends on the companion StepFi-API PR (adds POST /vouching/decline).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@prissca
prissca requested a review from EmeditWeb as a code owner July 27, 2026 03:07
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.

fix: send real decline request in Vouch page

2 participants