Skip to content

Commit 10aa721

Browse files
authored
Merge pull request #841 from Obiajulu-gif/fix/823-drip-action-error-handling
fix: surface errors for drip pause/cancel actions to user (closes #823)
2 parents 67294e4 + fd00545 commit 10aa721

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

  • frontend/src/app/dashboard/[campaignId]

frontend/src/app/dashboard/[campaignId]/page.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ export default function DashboardPage() {
348348
const [dripActionLoading, setDripActionLoading] = useState<string | null>(
349349
null,
350350
);
351+
const [dripActionError, setDripActionError] = useState<string | null>(null);
351352
const [trends, setTrends] = useState({
352353
totalRaised: "—",
353354
totalRaisedPositive: true,
@@ -577,6 +578,7 @@ export default function DashboardPage() {
577578

578579
async function handleDripAction(id: string, action: "paused" | "cancelled") {
579580
setDripActionLoading(id);
581+
setDripActionError(null);
580582
try {
581583
const res = await apiFetch(`${API_BASE_URL}/recurring-support/${id}`, {
582584
method: "PATCH",
@@ -585,9 +587,14 @@ export default function DashboardPage() {
585587
});
586588
if (res.ok) {
587589
setDrips((prev) => prev.filter((d) => d.id !== id));
590+
} else {
591+
const body = await res.json().catch(() => ({})) as Record<string, unknown>;
592+
setDripActionError(
593+
typeof body.error === "string" ? body.error : `Failed to ${action} drip`,
594+
);
588595
}
589596
} catch {
590-
// Silently fail
597+
setDripActionError("Connection error — please try again");
591598
} finally {
592599
setDripActionLoading(null);
593600
}
@@ -1165,6 +1172,12 @@ export default function DashboardPage() {
11651172
No active drips{isOwner ? " set up for this profile" : ""}.
11661173
</p>
11671174
) : (
1175+
<>
1176+
{dripActionError && (
1177+
<p className="mb-3 rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-2 text-xs text-red-400">
1178+
{dripActionError}
1179+
</p>
1180+
)}
11681181
<div className="space-y-3">
11691182
{drips.map((drip) => (
11701183
<div
@@ -1220,6 +1233,7 @@ export default function DashboardPage() {
12201233
</div>
12211234
))}
12221235
</div>
1236+
</>
12231237
)}
12241238
</section>
12251239
</div>

0 commit comments

Comments
 (0)