"use client";

import { useDeliveryHealth } from "@/modules/delivery/hooks/useDeliveryCapabilities";
import { DeliveryPageLoader, DeliveryPageError } from "@/modules/delivery/pages/shared";
import { PageHeader, Card, CardContent, Badge } from "@/components/ds";
import { DeliveryBreadcrumbs } from "@/modules/delivery/components/DeliveryBreadcrumbs";

export const HealthPage = function DeliveryHealthPage() {
  const q = useDeliveryHealth();
  if (q.isLoading) return <DeliveryPageLoader />;
  if (q.error) return <DeliveryPageError error={q.error} onRetry={() => q.refetch()} />;
  return (
    <div>
      <DeliveryBreadcrumbs current="سلامت سرویس" />
      <PageHeader title="سلامت سرویس" description="وضعیت delivery-service." />
      <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;
