"use client";
import { type ReactNode, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { Card } from "@/components/ui/card";
import { type Analytics, getAnalytics } from "@/lib/analytics";
// Clinic analytics computed on the server from real data (patients,
// appointments, prescriptions, tasks). No fabricated financials — temetro has no
// billing data source.
type Metric = { label: string; value: string };
function StatCard({ label, value }: Metric) {
return (
{label}
{value}
);
}
function Section({
title,
description,
children,
}: {
title: string;
description: string;
children: ReactNode;
}) {
return (
);
}
export function AnalysisView() {
const { t } = useTranslation();
const [data, setData] = useState(null);
useEffect(() => {
let active = true;
getAnalytics()
.then((a) => {
if (active) setData(a);
})
.catch(() => {
/* api-client redirects on 401; otherwise leave it loading */
});
return () => {
active = false;
};
}, []);
const n = (v: number | undefined) => String(v ?? 0);
return (
{t("analysis.title")}
{t("analysis.subtitle")}
);
}