Disable referral copy until link loads - #134
Conversation
Greptile SummaryThis PR disables the "Copy" button on the referrals page until the
Confidence Score: 4/5Safe to merge; the change is narrowly scoped to disabling a button during async load with matching test coverage. The implementation is correct and the new test covers the intended behavior. The only notable issue is that the if (!referralLink) guard inside copyLink is dead code — a disabled button never fires onClick, so that branch and its setError call will never execute. The guard block in copyLink (lines 66–69 of page.tsx) is worth a second glance; it is otherwise harmless but unreachable. Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant ReferralsPage
participant API as /api/referrals/code
ReferralsPage->>ReferralsPage: "mount (referralLink = "")"
Note over ReferralsPage: Copy button disabled
ReferralsPage->>API: fetch()
API-->>ReferralsPage: "{ code, link }"
ReferralsPage->>ReferralsPage: setReferralLink(link)
Note over ReferralsPage: Copy button enabled
User->>ReferralsPage: click Copy
ReferralsPage->>ReferralsPage: navigator.clipboard.writeText(referralLink)
Reviews (1): Last reviewed commit: "Disable referral copy until link loads" | Re-trigger Greptile |
| const copyLink = async () => { | ||
| if (!referralLink) { | ||
| setError("Referral link is still loading. Please try again."); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Dead guard — unreachable via UI
Because the Copy button is now disabled={!referralLink}, a disabled <button> won't fire onClick, so copyLink can never be called while referralLink is empty. The if (!referralLink) block and the setError(...) call inside it are dead code; the error message will never be displayed to the user through normal interaction. The guard can be removed without changing behavior.
Summary
/api/referrals/codehas populated a linkcopyLinkagainst empty referral-link valuesFixes #133
Validation
pnpm test:run src/app/dashboard/referrals/page.copy-loading.test.tsxpnpm type-checkpnpm exec eslint src/app/dashboard/referrals/page.tsx src/app/dashboard/referrals/page.copy-loading.test.tsxgit diff --checkBounty / payment
Submitted for the active uGig affiliate-program testing task. SOL receive address:
27sdMYXofqoM9qR13bZhccRNYeEgYn5EoHXTSJn4QWKP.Payment fallback: PayPal cultofrozen@gmail.com