fix: clinic creation gating, analysis line charts, username + task assignee, delete confirm

- Hide "Create clinic" (sidebar footer) for non-admins; only owner/admin can
  spin up additional clinics. Onboarding for brand-new users is unaffected.
- Analysis: drop the bar charts; show line charts (Sparkline) inside KPI cards
  that open a detail dialog with the full chart + per-point breakdown.
- Add Team Member: validate the username client-side (no spaces; letters,
  numbers, dots, underscores) with a clear warning + field hint.
- Tasks: New Task now has an Assignee selector (Myself / Other → department).
  Tasks are visible to the department they're assigned to (or the creator), and
  show who created them. Backend adds assignee_role + created_by_name with
  visibility filtering in listTasks; owners/admins see all.
- Care team: removing a member now asks for confirmation first (dialog) and
  surfaces success/failure + refreshes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Khalid Abdi
2026-06-08 19:52:12 +03:00
parent 8ab0552cf8
commit 4f8793c765
19 changed files with 2878 additions and 144 deletions
+27 -40
View File
@@ -3,7 +3,7 @@
import { type ReactNode, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { BarChart } from "@/components/analysis/bar-chart";
import { TrendCard } from "@/components/analysis/trend-card";
import { Card } from "@/components/ui/card";
import { type Analytics, getAnalytics } from "@/lib/analytics";
@@ -46,26 +46,6 @@ function Section({
);
}
// A full-width section that frames a single chart in a card.
function ChartSection({
title,
description,
children,
}: {
title: string;
description: string;
children: ReactNode;
}) {
return (
<section className="flex flex-col gap-3">
<div>
<h2 className="font-semibold text-lg tracking-tight">{title}</h2>
<p className="text-muted-foreground text-sm">{description}</p>
</div>
<Card className="p-5">{children}</Card>
</section>
);
}
export function AnalysisView() {
const { t } = useTranslation();
@@ -114,15 +94,32 @@ export function AnalysisView() {
/>
</Section>
<ChartSection
description={t("analysis.charts.patientGrowthDescription")}
title={t("analysis.charts.patientGrowthTitle")}
>
<BarChart
data={data?.trends.patientsByMonth ?? []}
emptyLabel={t("analysis.charts.empty")}
/>
</ChartSection>
<section className="flex flex-col gap-3">
<div>
<h2 className="font-semibold text-lg tracking-tight">
{t("analysis.charts.title")}
</h2>
<p className="text-muted-foreground text-sm">
{t("analysis.charts.subtitle")}
</p>
</div>
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
<TrendCard
description={t("analysis.charts.patientGrowthDescription")}
detailsLabel={t("analysis.charts.viewDetails")}
emptyLabel={t("analysis.charts.empty")}
points={data?.trends.patientsByMonth ?? []}
title={t("analysis.charts.patientGrowthTitle")}
/>
<TrendCard
description={t("analysis.charts.weeklyAppointmentsDescription")}
detailsLabel={t("analysis.charts.viewDetails")}
emptyLabel={t("analysis.charts.empty")}
points={data?.trends.appointmentsByWeekday ?? []}
title={t("analysis.charts.weeklyAppointmentsTitle")}
/>
</div>
</section>
<Section
description={t("analysis.appointments.description")}
@@ -146,16 +143,6 @@ export function AnalysisView() {
/>
</Section>
<ChartSection
description={t("analysis.charts.weeklyAppointmentsDescription")}
title={t("analysis.charts.weeklyAppointmentsTitle")}
>
<BarChart
data={data?.trends.appointmentsByWeekday ?? []}
emptyLabel={t("analysis.charts.empty")}
/>
</ChartSection>
<Section
description={t("analysis.prescriptions.description")}
title={t("analysis.prescriptions.title")}