import React, { useEffect, useState } from "react"; import { Dialog, DialogContent, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs"; import { Skeleton } from "@/components/ui/skeleton"; import { Button } from "@/components/ui/button"; import { ScrollArea } from "@/components/ui/scroll-area"; import { apiClient } from "@/lib/api-client"; import { useToast } from "@/components/ui/use-toast"; import { WebhookLog } from "@/lib/types"; interface WebhookDetailsDialogProps { logId: string; onClose: () => void; } export const WebhookDetailsDialog: React.FC = ({ logId, onClose, }) => { const [log, setLog] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [replayLoading, setReplayLoading] = useState(false); const { toast } = useToast(); useEffect(() => { const fetchLogDetails = async () => { try { setLoading(true); const response = await apiClient.get(`/webhook-logs/${logId}`); setLog(response.data); } catch (err) { setError("Failed to fetch webhook details"); console.error(err); } finally { setLoading(false); } }; fetchLogDetails(); }, [logId]); const handleReplay = async () => { if (!log) return; try { setReplayLoading(true); await apiClient.post(`/webhook-logs/${log.id}/replay`); toast({ title: "Webhook Replayed", description: "The webhook has been successfully replayed.", }); } catch (err) { console.error("Failed to replay webhook:", err); toast({ title: "Replay Failed", description: "Failed to replay the webhook. Please try again.", variant: "destructive", }); } finally { setReplayLoading(false); } }; return ( Webhook Details
{loading ? ( ) : error ? (
{error}
) : log ? ( <> Request Response

Status Code

{log.status_code}

) : null}
); }; // ... (ExpandableSection and WebhookDetailsSkeleton components remain the same) interface ExpandableSectionProps { title: string; content: string; } const ExpandableSection: React.FC = ({ title, content, }) => { const [isExpanded, setIsExpanded] = useState(true); const toggleExpand = () => setIsExpanded(!isExpanded); return (

{title}

          {JSON.stringify(JSON.parse(content), null, 2)}
        
); }; const WebhookDetailsSkeleton: React.FC = () => (
);