refactor: convert the requestCert writer to a React Query mutation - #1995
Open
brian-smith-tcril wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## bsmith/react-query-tour-button-cleanup #1995 +/- ##
==========================================================================
+ Coverage 92.87% 92.96% +0.08%
==========================================================================
Files 363 363
Lines 5938 5939 +1
Branches 1381 1381
==========================================================================
+ Hits 5515 5521 +6
+ Misses 403 399 -4
+ Partials 20 19 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The shared `requestCert` POST thunk is used by three tabs — CertificateStatusAlert (outline), CourseCelebration (course-exit), and CertificateStatus (progress). Convert all three to a `useRequestCert` mutation (fire-and-forget POST to generate_user_cert) and delete the thunk. Prerequisite below the outline-tab conversion so outline builds on an already-converted CertificateStatusAlert. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
brian-smith-tcril
force-pushed
the
bsmith/react-query-request-cert-mutation
branch
from
August 12, 2026 14:10
a891582 to
82889d7
Compare
brian-smith-tcril
marked this pull request as ready for review
August 12, 2026 16:41
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
Convert the shared
requestCertPOST thunk to auseRequestCertReact Query mutation and delete the thunk. Part of the Redux → React Query migration (#1946). Prerequisite below the outline-tab conversion (#1991) — outline'sCertificateStatusAlertis one of this thunk's three callers, so convertingrequestCertfirst lets outline build on an already-converted base. Closes #1994.requestCertis a fire-and-forget "request certificate" POST (postRequestCert→/courses/{courseId}/generate_user_cert) shared by three tabs, so all three callers convert together — the only way to delete the thunk rather than leave a redundant POST path.What changed
apiHooks.ts— adduseRequestCert(mutationFn: ({ courseId }) => postRequestCert(courseId),onError: logError), mirroring the other course-home mutations.dispatch(requestCert(courseId))touseRequestCert().mutate({ courseId }), dropping each file'suseDispatch+requestCertthunk import:course-home/outline-tab/alerts/certificate-status-alert/CertificateStatusAlert.jsxcourseware/course/course-exit/CourseCelebration.jsxcourse-home/progress-tab/certificate-status/CertificateStatus.jsxdata/thunks.js— delete therequestCertthunk and its now-unusedpostRequestCertimport. (requestCertisn't re-exported fromdata/index.js, so no re-export change.)Behavior
No user-facing change. The thunk and the mutation both call the same
postRequestCert(courseId)→ identical fire-and-forget POST, no response handling. The only delta isonError: logError(the thunk left failures unhandled) — a strict improvement.Testing
npm run types,npm run lint, and the fullnpm testsuite (106 suites, 3 pre-existing skips) pass. NewuseRequestCertcoverage inapiHooks.test.tsx(asserts the POST + error logging). All three callers' click paths are now exercised:ProgressTab.test.jsxandCourseExit.test.jsxclick the request-certificate button and assert thegenerate_user_certPOST fires;OutlineTab.test.jsxalready clicks it. (TheCourseExitclick test was added here — its button previously rendered but was never clicked, leaving themutateline uncovered.)Decisions
Full decision log
Decisions — convert the requestCert writer to a React Query mutation (#1994)
Working notes for this PR (part of the Redux → React Query migration, #1946).
Not checked in. A prerequisite below the outline-tab conversion (#1991).
Whole-writer conversion, not per-tab
Decision. Convert
requestCertacross all three of its callers in onePR and delete the thunk, rather than converting per-tab:
outline-tab/.../CertificateStatusAlert.jsx(outline)courseware/course/course-exit/CourseCelebration.jsx(course-exit)progress-tab/certificate-status/CertificateStatus.jsx(progress)Why.
requestCertis a single shared thunk with three callers. To actuallydelete the thunk (not just relocate a redundant POST path), every caller must
stop using it. This surfaced while converting the outline tab (#1991): deleting
the thunk there would have broken course-exit and progress, which also dispatch
it.
Its own layer, below outline
Decision.
requestCertconverts in a dedicated layer beneath theoutline-tab conversion (#1991), not folded into it.
Why. Outline's
CertificateStatusAlertis one of the three callers. Landingthe writer conversion below outline lets the outline PR build on an
already-converted
CertificateStatusAlertand keeps a shared-code change out ofthe tab-conversion diff. (
dismissWelcomeMessage, which is genuinelyoutline-only, stays in the outline PR.)
Behavior-preserving
Decision.
useRequestCertis a fire-and-forget mutation calling the samepostRequestCert(courseId)the thunk did;onError: logErroris the only delta.Why. Both paths POST to
/courses/{courseId}/generate_user_certwith noresponse handling. The thunk left failures unhandled; the mutation logs them — a
strict improvement, no user-facing change.
🤖 Generated with Claude Code