Split bounty detail CTA components and share state hook - #224
Split bounty detail CTA components and share state hook#22418060910075zx-coder wants to merge 4 commits into
Conversation
|
@18060910075zx-coder is attempting to deploy a commit to the Threadflow Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThis PR refactors the bounty call-to-action (CTA) components by extracting shared state logic into a new ChangesCTA state extraction and component split
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@components/bounty-detail/bounty-detail-mobile-cta.tsx`:
- Around line 142-170: The mobile cancel dialog preserves the previous
cancelReason after closing; update the dialog close flow so cancelReason is
cleared when the dialog closes. In the AlertDialog controlled by
cancelDialogOpen (onOpenChange={setCancelDialogOpen}), detect when open becomes
false and call setCancelReason('') (or reset to initial value); alternatively
add an effect that watches cancelDialogOpen and resets cancelReason when it
transitions to false. Ensure this reset runs only on close and keep existing
isCancelling checks intact so the textarea and buttons behave correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f5935444-4615-42fa-96ff-94c863e25b32
📒 Files selected for processing (4)
components/bounty-detail/bounty-detail-client.tsxcomponents/bounty-detail/bounty-detail-mobile-cta.tsxcomponents/bounty-detail/bounty-detail-sidebar-cta.tsxcomponents/bounty-detail/use-bounty-cta-state.ts
| <AlertDialog open={cancelDialogOpen} onOpenChange={setCancelDialogOpen}> | ||
| <AlertDialogContent> | ||
| <AlertDialogHeader> | ||
| <AlertDialogTitle className="flex items-center gap-2 text-red-400"> | ||
| <XCircle className="size-5" /> | ||
| Cancel Bounty | ||
| </AlertDialogTitle> | ||
| <AlertDialogDescription> | ||
| This will cancel the bounty and refund escrowed funds. This action | ||
| cannot be undone. | ||
| </AlertDialogDescription> | ||
| </AlertDialogHeader> | ||
| <div className="space-y-2"> | ||
| <Label htmlFor="mobile-cancel-reason"> | ||
| Reason <span className="text-red-400">*</span> | ||
| </Label> | ||
| <Textarea | ||
| id="mobile-cancel-reason" | ||
| placeholder="Reason for cancellation..." | ||
| value={cancelReason} | ||
| onChange={(e) => setCancelReason(e.target.value)} | ||
| className="min-h-20" | ||
| disabled={isCancelling} | ||
| /> | ||
| </div> | ||
| <AlertDialogFooter> | ||
| <AlertDialogCancel disabled={isCancelling}> | ||
| Keep Bounty | ||
| </AlertDialogCancel> |
There was a problem hiding this comment.
Reset cancelReason on mobile dialog close to avoid stale destructive state.
The mobile cancel dialog currently preserves the previous reason after close, which can reopen with pre-filled state and an already-enabled destructive button.
Proposed fix
- <AlertDialog open={cancelDialogOpen} onOpenChange={setCancelDialogOpen}>
+ <AlertDialog
+ open={cancelDialogOpen}
+ onOpenChange={(open) => {
+ setCancelDialogOpen(open);
+ if (!open) setCancelReason("");
+ }}
+ >
@@
- <AlertDialogCancel disabled={isCancelling}>
+ <AlertDialogCancel
+ disabled={isCancelling}
+ onClick={() => setCancelReason("")}
+ >🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@components/bounty-detail/bounty-detail-mobile-cta.tsx` around lines 142 -
170, The mobile cancel dialog preserves the previous cancelReason after closing;
update the dialog close flow so cancelReason is cleared when the dialog closes.
In the AlertDialog controlled by cancelDialogOpen
(onOpenChange={setCancelDialogOpen}), detect when open becomes false and call
setCancelReason('') (or reset to initial value); alternatively add an effect
that watches cancelDialogOpen and resets cancelReason when it transitions to
false. Ensure this reset runs only on close and keep existing isCancelling
checks intact so the textarea and buttons behave correctly.
|
Thanks for reviewing. I saw this was closed without a note; I pushed the CodeRabbit fix for the stale mobile cancel reason. If there are project-specific reasons this should stay closed, no worries, but if changes are needed I can adjust quickly. |
Summary
Closes #209.
Splits
bounty-detail-sidebar-cta.tsxinto separate desktop/mobile CTA files and moves the shared state/action logic intouse-bounty-cta-state.ts.Changes
bounty-detail-sidebar-cta.tsxnow exports onlySidebarCTAbounty-detail-mobile-cta.tsxexportingMobileCTAuse-bounty-cta-state.tsfor shared CTA state and handlers:bounty-detail-client.tsxto importMobileCTAfrom the new filevariant="outline"prop and duplicated deadline helper block while preserving the rendered behaviorVerification
bounty-detail-sidebar-cta.tsx: 296 linesbounty-detail-mobile-cta.tsx: 184 linesuse-bounty-cta-state.ts: 120 linesNotes
I could not run the full local app test suite because cloning/installing dependencies from GitHub/npm is intermittently timing out in this environment, so this PR is scoped to the requested component split with static verification.
Summary by CodeRabbit