fix: send real decline request in Vouch page - #93
Open
prissca wants to merge 1 commit into
Open
Conversation
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>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
handleDeclineusedsetTimeout(() => 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: addeddeclineVouch(learnerAddress), matching the existingsubmitVouch/revokeVouchcall shape.useOptimisticVouch.ts: addeduseDeclineVouch(), mirroringuseRevokeVouch's optimistic-update/rollback pattern.Vouch.tsx:handleDeclinenow callsdeclineMutation.mutateinstead of faking a delay. The existingdeclining/loading prop onVouchRequestCard(already wired to show a spinner) now reflects a real in-flight request, and a failure surfaces via the existing toast error pattern.optimisticMutations.test.tswithuseDeclineVouchcoverage (optimistic removal + persistence on success, rollback on failure).Depends on: StepFi-app/StepFi-API#109
Closes #66
Test plan
node_moduleshere has a broken/incomplete native optional dependency (@rolldown/binding-win32-x64-msvcmissing) unrelated to this change; please runnpm testafternpm i