"use client"; import { useQuery } from "@tanstack/react-query"; import { useState } from "react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Skeleton } from "@/components/ui/skeleton"; import { StatusBadge, statusFromServer } from "@/components/StatusBadge"; type ServerStatus = { online: boolean; starting?: boolean; players: { online: number; max: number }; version?: string; motd?: string; }; export function StatusCard() { const [copied, setCopied] = useState(false); const { data, isLoading } = useQuery({ queryKey: ["status"], queryFn: () => fetch("/api/status").then((r) => r.json()), refetchInterval: 15000, }); const copyIP = () => { navigator.clipboard.writeText("minecraft.hurkicorgi.com"); setCopied(true); setTimeout(() => setCopied(false), 1500); }; return ( Server Status
{/* Status */}

Status

{isLoading || !data ? ( ) : ( )}
{/* Players */}

Players

{isLoading || !data ? ( ) : (

{data.online ? `${data.players.online}/${data.players.max}` : "0"}

)}
{/* Version */}

Version

{isLoading || !data ? ( ) : (

{data.version || "-"}

)}
{/* Connect */}

Connect

); }