Skip to content

Commit d1609c2

Browse files
committed
connect the replay API to frontend
1 parent d39bfbd commit d1609c2

6 files changed

Lines changed: 606 additions & 34 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
export async function POST(req: Request) {
3+
console.log("Webhook received")
4+
return new Response("ok", { status: 200 })
5+
}

web/src/app/delivery-targets/[id]/delivery-target-detail-client.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { UserNav } from "@/components/user-nav"
1313
import { useState } from "react"
1414
import type { DeliveryTarget, TargetStats } from "@/types/delivery-target"
1515

16+
import TargetLogs from "../target-logs"
17+
1618

1719

1820

@@ -146,19 +148,23 @@ export default function DeliveryTargetDetailClient({
146148
<h2 className="font-semibold mb-4">Observability Insight</h2>
147149

148150
<p className="text-sm text-muted-foreground">
149-
{successRate >= 98
150-
? "Delivery pipeline is highly stable with minimal failure rate."
151-
: successRate >= 90
152-
? "Minor delivery issues detected. Monitor retry behavior."
153-
: "Significant failures detected. Check endpoint health, retries, or configuration."}
151+
{successRate >= 98
152+
? "Delivery pipeline is highly stable with minimal failure rate."
153+
: successRate >= 90
154+
? "Minor delivery issues detected. Monitor retry behavior."
155+
: "Significant failures detected. Check endpoint health, retries, or configuration."}
154156
</p>
155157
</div>
158+
<TargetLogs targetId={target.id} />
156159

157160
</div>
158161
</div>
159162
)
160163
}
161164

165+
166+
167+
162168
/* ---------------- UI ---------------- */
163169

164170
function Card({
@@ -176,6 +182,8 @@ function Card({
176182
>
177183
<p className="text-sm text-muted-foreground">{label}</p>
178184
<p className="text-xl font-bold">{value}</p>
185+
179186
</motion.div>
180187
)
188+
181189
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
"use client"
2+
3+
import { useEffect, useState } from "react"
4+
import { CheckCircle2, XCircle, Clock } from "lucide-react"
5+
6+
type Log = {
7+
id: string
8+
event_id: number
9+
status: "success" | "failed"
10+
status_code?: number
11+
response?: string
12+
attempt: number
13+
created_at: string
14+
}
15+
16+
export default function TargetLogs({ targetId }: { targetId: string }) {
17+
const [logs, setLogs] = useState<Log[]>([])
18+
const [loading, setLoading] = useState(true)
19+
20+
useEffect(() => {
21+
fetch(`${process.env.NEXT_PUBLIC_API_URL}/delivery-targets/${targetId}/logs`)
22+
.then(res => res.json())
23+
.then(data => setLogs(data.items || []))
24+
.finally(() => setLoading(false))
25+
}, [targetId])
26+
27+
if (loading) {
28+
return (
29+
<div className="p-6 text-sm text-muted-foreground">
30+
Loading logs...
31+
</div>
32+
)
33+
}
34+
35+
return (
36+
<div className="rounded-xl border bg-card overflow-hidden">
37+
38+
<div className="px-4 py-3 border-b text-sm font-medium">
39+
Delivery Logs
40+
</div>
41+
42+
<div className="divide-y">
43+
{logs.length === 0 && (
44+
<div className="p-6 text-sm text-muted-foreground">
45+
No deliveries yet
46+
</div>
47+
)}
48+
49+
{logs.map(log => (
50+
<div
51+
key={log.id}
52+
className="flex items-center justify-between p-4 hover:bg-muted/40 transition"
53+
>
54+
{/* LEFT */}
55+
<div className="flex items-center gap-3">
56+
57+
{log.status === "success" && (
58+
<CheckCircle2 className="w-4 h-4 text-emerald-500" />
59+
)}
60+
61+
{log.status === "failed" && (
62+
<XCircle className="w-4 h-4 text-rose-500" />
63+
)}
64+
65+
<div>
66+
<p className="text-sm font-medium">
67+
Event #{log.event_id}
68+
</p>
69+
70+
<p className="text-xs text-muted-foreground">
71+
Attempt {log.attempt}{log.status_code || "—"}
72+
</p>
73+
</div>
74+
</div>
75+
76+
{/* RIGHT */}
77+
<div className="text-xs text-muted-foreground">
78+
{new Date(log.created_at).toLocaleTimeString()}
79+
</div>
80+
</div>
81+
))}
82+
</div>
83+
</div>
84+
)
85+
}

0 commit comments

Comments
 (0)