"use client";

import { useQuery } from "@tanstack/react-query";
import { hospitalityApi } from "@/modules/hospitality/services/hospitality-api";
import { HospitalityPageLoader, HospitalityPageError } from "@/modules/hospitality/pages/shared";
import { PageHeader, Card, CardContent, Badge } from "@/components/ds";

export const HealthPage = function HospitalityHealthPage() {
  const q = useQuery({ queryKey: ["hospitality", "health"], queryFn: () => hospitalityApi.health() });
  if (q.isLoading) return <HospitalityPageLoader />;
  if (q.error) return <HospitalityPageError error={q.error} onRetry={() => q.refetch()} />;
  return (
    <div>
      <PageHeader title="سلامت سرویس" description="وضعیت سرویس Hospitality." />
      <Card><CardContent className="space-y-2 p-4">
        <Badge tone={q.data?.status === "ok" ? "success" : "danger"}>{q.data?.status}</Badge>
        <p className="text-sm">{q.data?.service} — v{q.data?.version}</p>
      </CardContent></Card>
    </div>
  );
};
export default HealthPage;
