mirror of
https://github.com/temetro/temetro.git
synced 2026-08-13 20:16:53 +00:00
3aa699aefe
real Live card, persistent chat history Analytics & earnings: - Analytics now carries real money computed from invoices (billed/paid/ outstanding + by-month); new Earnings section on the Analysis page drawn with the project's Bklit chart components (shared EarningsChart). AI agent reaches the whole clinic: - new read tools getClinicInfo / getAnalytics / listInventory render clinic, analytics (with a Bklit earnings chart) and inventory cards in chat - proposeInvoice turns an uploaded purchase/medication list into an invoice (new "invoice" action-preview kind → createInvoice); invoices/appointments auto-create/link a patient (ensurePatient) so they hit the Patients page Live card: - plots real data — patients checked in today — via GET /api/analytics/live (polled); value pill clamped and margins widened so nothing spills the card Persistent AI chat history (Claude-style): - ai_chat_threads + ai_chat_messages (migration 0016); per-user, org-scoped thread CRUD under /api/chat/threads - chat panel owns a thread id, loads /?thread=<id>, and auto-saves after each exchange; sidebar lists past chats (open/delete), "New chat" starts fresh Verified with backend typecheck + frontend tsc + next build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
"use client";
|
|
|
|
import { Building2 } from "lucide-react";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import { Card } from "@/components/ui/card";
|
|
import type { ClinicCardData } from "@/lib/ai-chat";
|
|
|
|
// Small card the agent shows for getClinicInfo.
|
|
export function ClinicCard({ data }: { data: ClinicCardData }) {
|
|
const { t } = useTranslation();
|
|
const since = data.createdAt
|
|
? new Date(data.createdAt).toLocaleDateString("en-US", {
|
|
month: "short",
|
|
year: "numeric",
|
|
})
|
|
: null;
|
|
return (
|
|
<Card className="w-full gap-1 p-4">
|
|
<div className="flex items-center gap-2">
|
|
<Building2 className="size-4 text-muted-foreground" />
|
|
<span className="text-muted-foreground text-xs">
|
|
{t("chat.clinicCard.title")}
|
|
</span>
|
|
</div>
|
|
<span className="font-semibold text-foreground text-lg tracking-tight">
|
|
{data.name}
|
|
</span>
|
|
{since ? (
|
|
<span className="text-muted-foreground text-xs">
|
|
{t("chat.clinicCard.since", { date: since })}
|
|
</span>
|
|
) : null}
|
|
</Card>
|
|
);
|
|
}
|