feat: add cancel/refund flow with contributor-first escrow refund#656
feat: add cancel/refund flow with contributor-first escrow refund#656BWM0223 wants to merge 1 commit into
Conversation
|
@BWM0223 is attempting to deploy a commit to the Threadflow Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughAdds a client-side ChangesCancel refund flow
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 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)
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
🧹 Nitpick comments (1)
components/bounty/CancelRefundFlow.tsx (1)
17-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse a typed const arrow component per project TS/React style.
Lines 17-19 use a function declaration; project guidance asks for const arrow functions with explicit typing.
As per coding guidelines, "**/*.{js,jsx,ts,tsx}: Prefer const arrow functions with explicit type annotations over function declarations".Suggested refactor
-export function CancelRefundFlow({ +export const CancelRefundFlow = ({ bountyId, bountyTitle, escrowBalance, contributorCount, onCancel, onClose -}: CancelRefundFlowProps) { +}: CancelRefundFlowProps): JSX.Element => { const [step, setStep] = useState<"confirm" | "processing" | "done">("confirm"); const [error, setError] = useState<string | null>(null); @@ -} +};🤖 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/CancelRefundFlow.tsx` around lines 17 - 20, The CancelRefundFlow component is declared as a function declaration, but the project style requires typed const arrow components. Refactor CancelRefundFlow to a const arrow function with an explicit component type annotation, keeping the existing props and internal state logic unchanged so the symbol remains easy to locate and consistent with the TS/React style used elsewhere.Source: Coding guidelines
🤖 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/CancelRefundFlow.tsx`:
- Around line 29-31: The catch handler in CancelRefundFlow should not use any;
update the catch clause to unknown and narrow the value before reading message.
In the error-handling path around setError and setStep, add a type guard or
instanceof Error check so only Error-like values access message, and keep the
fallback "Cancellation failed" for non-Error cases.
---
Nitpick comments:
In `@components/bounty/CancelRefundFlow.tsx`:
- Around line 17-20: The CancelRefundFlow component is declared as a function
declaration, but the project style requires typed const arrow components.
Refactor CancelRefundFlow to a const arrow function with an explicit component
type annotation, keeping the existing props and internal state logic unchanged
so the symbol remains easy to locate and consistent with the TS/React style used
elsewhere.
🪄 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: 40b431a0-b087-4640-8228-47192486c306
📒 Files selected for processing (1)
components/bounty/CancelRefundFlow.tsx
| } catch (e: any) { | ||
| setError(e.message ?? "Cancellation failed"); | ||
| setStep("confirm"); |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major
Replace any with unknown in error handling.
Line 29 uses any, which violates the type safety guidelines. Update the catch clause to accept unknown and use type narrowing before accessing properties.
Suggested fix
const handleCancel = async () => {
setStep("processing");
setError(null);
try {
await onCancel(bountyId);
setStep("done");
- } catch (e: any) {
- setError(e.message ?? "Cancellation failed");
+ } catch (error: unknown) {
+ const message = error instanceof Error ? error.message : "Cancellation failed";
+ setError(message);
setStep("confirm");
}
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| } catch (e: any) { | |
| setError(e.message ?? "Cancellation failed"); | |
| setStep("confirm"); | |
| } catch (error: unknown) { | |
| const message = error instanceof Error ? error.message : "Cancellation failed"; | |
| setError(message); | |
| setStep("confirm"); |
🤖 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/CancelRefundFlow.tsx` around lines 29 - 31, The catch
handler in CancelRefundFlow should not use any; update the catch clause to
unknown and narrow the value before reading message. In the error-handling path
around setError and setStep, add a type guard or instanceof Error check so only
Error-like values access message, and keep the fallback "Cancellation failed"
for non-Error cases.
Summary
Fixes #634 - FE: Cancel / refund flow
Changes
Summary by CodeRabbit