diff --git a/client/src/components/PingTab.tsx b/client/src/components/PingTab.tsx index 65469016..a411993e 100644 --- a/client/src/components/PingTab.tsx +++ b/client/src/components/PingTab.tsx @@ -1,21 +1,67 @@ import { TabsContent } from "@/components/ui/tabs"; import { Button } from "@/components/ui/button"; +import { Bell } from "lucide-react"; +import { useState } from "react"; +import { useToast } from "@/lib/hooks/useToast"; + +interface PingTabProps { + onPingClick?: () => Promise | void; +} + +export default function PingTab({ onPingClick }: PingTabProps) { + const [isPinging, setIsPinging] = useState(false); + const { toast } = useToast(); + + const handlePingClick = async () => { + try { + setIsPinging(true); + + // Show loading toast + toast({ + title: "Ping Initiated", + description: "Sending ping request to the server...", + duration: 5000, // Auto-dismiss after 5 seconds + }); + + if (onPingClick) { + await onPingClick(); + } + + // Show success toast when ping completes + toast({ + title: "Ping Successful", + description: "Server responded to ping request", + variant: "default", + duration: 5000, // Auto-dismiss after 5 seconds + }); + } catch (error) { + // Show error toast if ping fails + toast({ + title: "Ping Failed", + description: + error instanceof Error ? error.message : "Failed to ping server", + variant: "destructive", + duration: 5000, // Auto-dismiss after 5 seconds + }); + } finally { + setIsPinging(false); + } + }; -const PingTab = ({ onPingClick }: { onPingClick: () => void }) => { return (
-
+
); -}; - -export default PingTab; +}