diff --git a/components/bounty/CancelRefundFlow.tsx b/components/bounty/CancelRefundFlow.tsx new file mode 100644 index 000000000..06b56c0ee --- /dev/null +++ b/components/bounty/CancelRefundFlow.tsx @@ -0,0 +1,83 @@ + +"use client"; +import { useState } from "react"; +import { Button } from "@/components/ui/button"; +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; +import { AlertTriangle, XCircle } from "lucide-react"; + +interface CancelRefundFlowProps { + bountyId: string; + bountyTitle: string; + escrowBalance: number; + contributorCount: number; + onCancel: (bountyId: string) => Promise; + onClose: () => void; +} + +export function CancelRefundFlow({ + bountyId, bountyTitle, escrowBalance, contributorCount, onCancel, onClose +}: CancelRefundFlowProps) { + const [step, setStep] = useState<"confirm" | "processing" | "done">("confirm"); + const [error, setError] = useState(null); + + const handleCancel = async () => { + setStep("processing"); + setError(null); + try { + await onCancel(bountyId); + setStep("done"); + } catch (e: any) { + setError(e.message ?? "Cancellation failed"); + setStep("confirm"); + } + }; + + return ( + + + + + {step === "done" ? "Bounty Cancelled" : "Cancel Bounty"} + + {bountyTitle} + + + {step === "confirm" && ( + <> +
+
+ +
+

Refund order

+
    +
  1. Contributors refunded first ({contributorCount} contributor{contributorCount !== 1 ? "s" : ""})
  2. +
  3. Remaining escrow balance returned to you
  4. +
+
+
+

+ Escrow balance: {escrowBalance} USDC +

+
+ {error &&

{error}

} +
+ + +
+ + )} + {step === "processing" && ( +

Processing cancellation and refunds...

+ )} + {step === "done" && ( +
+

Bounty cancelled. Refunds are being processed.

+ +
+ )} +
+
+ ); +} + +export default CancelRefundFlow;