frontend: COSS checkbox/table + fewer toolbar/sheet buttons

- Invoice dialog: the Back-date / Due-date toggles now use the COSS Checkbox
  instead of raw, misshapen native checkboxes.
- Patients page: rebuilt the list as a COSS Table in a CardFrame, and moved
  "Import from a patient app" into a ⋯ overflow menu so the toolbar keeps one
  primary "Add patient" CTA.
- Patient detail sheet: collapsed the five header buttons + delete into a
  primary Edit action plus a ⋯ More menu (Download summary, Record visit,
  Transfer, Push to wallet, and a destructive Delete).
- Added the COSS table + checkbox primitives; new i18n keys across all locales.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Khalid Abdi
2026-07-13 02:11:06 +03:00
parent 7846dacd42
commit bd8fdfadda
10 changed files with 402 additions and 126 deletions
@@ -12,6 +12,7 @@ import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
import { Calendar } from "@/components/ui/calendar";
import { Checkbox } from "@/components/ui/checkbox";
import { Combobox, type ComboboxOption } from "@/components/ui/combobox";
import {
Dialog,
@@ -367,11 +368,14 @@ export function InvoiceFormDialog({
<div className="flex flex-col gap-1.5">
<span className="flex items-center justify-between gap-2 text-muted-foreground text-xs">
{t("invoices.dialog.issued")}
<label className="flex items-center gap-1 text-[11px]">
<input
<label
className="flex items-center gap-1.5 text-[11px]"
htmlFor="invoice-backdate"
>
<Checkbox
checked={allowBackdate}
onChange={(e) => setAllowBackdate(e.target.checked)}
type="checkbox"
id="invoice-backdate"
onCheckedChange={(checked) => setAllowBackdate(checked)}
/>
{t("invoices.dialog.backdate")}
</label>
@@ -385,11 +389,10 @@ export function InvoiceFormDialog({
<div className="flex flex-col gap-1.5">
<span className="flex items-center justify-between text-muted-foreground text-xs">
{t("invoices.dialog.due")}
<input
<Checkbox
aria-label={t("invoices.dialog.due")}
checked={hasDue}
onChange={(e) => setHasDue(e.target.checked)}
type="checkbox"
onCheckedChange={(checked) => setHasDue(checked)}
/>
</span>
{hasDue ? (
+49 -41
View File
@@ -7,6 +7,7 @@ import {
type LucideIcon,
ListTodo,
Mic,
MoreHorizontal,
Network,
NotebookPen,
Pencil,
@@ -29,6 +30,13 @@ import {
import { printPatientSummary } from "@/lib/patient-pdf";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import {
Menu,
MenuItem,
MenuPopup,
MenuSeparator,
MenuTrigger,
} from "@/components/ui/menu";
import {
Dialog,
DialogClose,
@@ -315,63 +323,63 @@ export function PatientDetail({
)}
</div>
</div>
{/* Actions — their own wrapping row beneath the identity. */}
<div className="flex flex-wrap items-center gap-2">
<Button
onClick={() => printPatientSummary(patient, t)}
size="sm"
type="button"
variant="outline"
>
<FileDown className="size-4" />
{t("patientCard.exportPdf")}
</Button>
{onTransfer && (
<Button
onClick={onTransfer}
size="sm"
type="button"
variant="outline"
>
<ArrowLeftRight className="size-4" />
{t("patients.transfer.action")}
</Button>
)}
{onScribe && (
<Button onClick={onScribe} size="sm" type="button" variant="outline">
<Mic className="size-4" />
{t("scribe.recordVisit")}
</Button>
)}
{/* Actions — one primary (Edit) with the rest tucked into an overflow
menu so the header stays uncluttered. */}
<div className="flex items-center gap-2">
{onEdit && (
<Button onClick={onEdit} size="sm" type="button" variant="outline">
<Pencil className="size-4" />
{t("patientCard.edit")}
</Button>
)}
{onWalletPush && (
<Menu>
<MenuTrigger
render={
<Button
onClick={onWalletPush}
size="sm"
aria-label={t("patientCard.moreActions")}
className="ms-auto"
size="icon-sm"
type="button"
variant="outline"
/>
}
>
<MoreHorizontal className="size-4" />
</MenuTrigger>
<MenuPopup align="end">
<MenuItem onClick={() => printPatientSummary(patient, t)}>
<FileDown className="size-4" />
{t("patientCard.exportPdf")}
</MenuItem>
{onScribe && (
<MenuItem onClick={onScribe}>
<Mic className="size-4" />
{t("scribe.recordVisit")}
</MenuItem>
)}
{onTransfer && (
<MenuItem onClick={onTransfer}>
<ArrowLeftRight className="size-4" />
{t("patients.transfer.action")}
</MenuItem>
)}
{onWalletPush && (
<MenuItem onClick={onWalletPush}>
<Send className="size-4" />
{t("walletPush.action")}
</Button>
</MenuItem>
)}
{onDelete && (
<Button
aria-label={t("patients.delete.action")}
className="ms-auto"
onClick={onDelete}
size="sm"
type="button"
variant="destructive"
>
<>
<MenuSeparator />
<MenuItem onClick={onDelete} variant="destructive">
<Trash2 className="size-4" />
</Button>
{t("patients.delete.action")}
</MenuItem>
</>
)}
</MenuPopup>
</Menu>
</div>
</div>
+95 -59
View File
@@ -1,6 +1,6 @@
"use client";
import { Plus, Search, Smartphone } from "lucide-react";
import { MoreHorizontal, Plus, Search, Smartphone } from "lucide-react";
import { useSearchParams } from "next/navigation";
import { useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
@@ -11,8 +11,15 @@ import { ImportFromWalletDialog } from "@/components/patients/import-from-wallet
import { PatientDetailSheet } from "@/components/patients/patient-detail-sheet";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { CardFrame } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { ListPagination } from "@/components/ui/list-pagination";
import {
Menu,
MenuItem,
MenuPopup,
MenuTrigger,
} from "@/components/ui/menu";
import {
Select,
SelectItem,
@@ -20,6 +27,14 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
import { listPatients, type Patient } from "@/lib/patients";
type StatusFilter = "all" | Patient["status"];
@@ -181,15 +196,6 @@ export function PatientsView() {
))}
</SelectPopup>
</Select>
<Button
className="rounded-3xl"
onClick={() => setImportOpen(true)}
type="button"
variant="outline"
>
<Smartphone className="size-4" />
{t("patients.importFromApp")}
</Button>
<Button
className="rounded-3xl"
onClick={() => {
@@ -201,58 +207,88 @@ export function PatientsView() {
<Plus className="size-4" />
{t("patients.add")}
</Button>
{/* Secondary actions tuck into an overflow menu so the toolbar keeps a
single primary CTA. */}
<Menu>
<MenuTrigger
render={
<Button
aria-label={t("patients.moreActions")}
className="rounded-full"
size="icon"
type="button"
variant="outline"
/>
}
>
<MoreHorizontal className="size-4" />
</MenuTrigger>
<MenuPopup align="end">
<MenuItem onClick={() => setImportOpen(true)}>
<Smartphone className="size-4" />
{t("patients.importFromApp")}
</MenuItem>
</MenuPopup>
</Menu>
</div>
</div>
<div className="mt-8 overflow-hidden rounded-2xl border border-border bg-card/30">
<table className="w-full text-sm">
<thead>
<tr className="border-border border-b text-start text-xs text-muted-foreground uppercase">
<th className="px-4 py-3 font-medium">{t("patients.columns.name")}</th>
<th className="px-4 py-3 font-medium">{t("patients.columns.mrn")}</th>
<th className="px-4 py-3 font-medium">
<CardFrame className="mt-8 w-full">
<Table variant="card">
<TableHeader>
<TableRow>
<TableHead className="ps-4 text-xs uppercase">
{t("patients.columns.name")}
</TableHead>
<TableHead className="text-xs uppercase">
{t("patients.columns.mrn")}
</TableHead>
<TableHead className="text-xs uppercase">
{t("patients.columns.ageSex")}
</th>
<th className="px-4 py-3 font-medium">
</TableHead>
<TableHead className="text-xs uppercase">
{t("patients.columns.status")}
</th>
<th className="px-4 py-3 font-medium">
</TableHead>
<TableHead className="text-xs uppercase">
{t("patients.columns.lastSeen")}
</th>
<th className="px-4 py-3 font-medium">
</TableHead>
<TableHead className="pe-4 text-xs uppercase">
{t("patients.columns.allergies")}
</th>
</tr>
</thead>
<tbody>
</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{loading ? (
<tr>
<td
className="px-4 py-10 text-center text-muted-foreground"
<TableRow>
<TableCell
className="py-10 text-center text-muted-foreground"
colSpan={6}
>
{t("patients.loading")}
</td>
</tr>
</TableCell>
</TableRow>
) : loadError ? (
<tr>
<td className="px-4 py-10 text-center text-destructive" colSpan={6}>
<TableRow>
<TableCell
className="py-10 text-center text-destructive"
colSpan={6}
>
{loadError}
</td>
</tr>
</TableCell>
</TableRow>
) : patients.length === 0 ? (
<tr>
<td
className="px-4 py-10 text-center text-muted-foreground"
<TableRow>
<TableCell
className="py-10 text-center text-muted-foreground"
colSpan={6}
>
{t("patients.empty")}
</td>
</tr>
</TableCell>
</TableRow>
) : (
pageRows.map((p) => (
<tr
className="cursor-pointer border-border/50 border-b transition-colors last:border-0 hover:bg-accent/50"
<TableRow
className="cursor-pointer"
key={p.fileNumber}
onClick={() => open(p.fileNumber)}
onKeyDown={(event) => {
@@ -264,7 +300,7 @@ export function PatientsView() {
role="button"
tabIndex={0}
>
<td className="px-4 py-3 font-medium text-foreground">
<TableCell className="ps-4 py-3 font-medium text-foreground">
<span className="flex items-center gap-2">
{p.name}
<AiBadge source={p.source} />
@@ -274,30 +310,30 @@ export function PatientsView() {
</Badge>
) : null}
</span>
</td>
<td className="px-4 py-3 text-muted-foreground">
</TableCell>
<TableCell className="py-3 text-muted-foreground">
{p.fileNumber}
</td>
<td className="px-4 py-3 text-muted-foreground">
</TableCell>
<TableCell className="py-3 text-muted-foreground">
{p.age} · {p.sex}
</td>
<td className="px-4 py-3">
</TableCell>
<TableCell className="py-3">
<Badge variant={statusVariant[p.status]}>
{t(`patients.status.${p.status}`)}
</Badge>
</td>
<td className="px-4 py-3 text-muted-foreground">
</TableCell>
<TableCell className="py-3 text-muted-foreground">
{p.encounters[0]?.date ?? "—"}
</td>
<td className="px-4 py-3 text-muted-foreground">
</TableCell>
<TableCell className="pe-4 py-3 text-muted-foreground">
{p.allergies.length || "—"}
</td>
</tr>
</TableCell>
</TableRow>
))
)}
</tbody>
</table>
</div>
</TableBody>
</Table>
</CardFrame>
{!loading && !loadError ? (
<ListPagination
+68
View File
@@ -0,0 +1,68 @@
"use client";
import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox";
import type React from "react";
import { cn } from "@/lib/utils";
export function Checkbox({
className,
...props
}: CheckboxPrimitive.Root.Props): React.ReactElement {
return (
<CheckboxPrimitive.Root
className={cn(
"relative inline-flex size-4.5 shrink-0 items-center justify-center rounded-[.25rem] border border-input bg-background not-dark:bg-clip-padding shadow-xs/5 outline-none ring-ring transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[3px] not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background aria-invalid:border-destructive/36 focus-visible:aria-invalid:border-destructive/64 focus-visible:aria-invalid:ring-destructive/48 data-disabled:cursor-not-allowed data-disabled:opacity-64 sm:size-4 dark:not-data-checked:bg-input/32 dark:aria-invalid:ring-destructive/24 dark:not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/6%)] [[data-disabled],[data-checked],[aria-invalid]]:shadow-none",
className,
)}
data-slot="checkbox"
{...props}
>
<CheckboxPrimitive.Indicator
className="absolute -inset-px flex items-center justify-center rounded-[.25rem] text-primary-foreground data-unchecked:hidden data-checked:bg-primary data-indeterminate:text-foreground"
data-slot="checkbox-indicator"
render={(
props: React.ComponentProps<"span">,
state: CheckboxPrimitive.Indicator.State,
) => (
<span {...props}>
{state.indeterminate ? (
<svg
aria-hidden="true"
className="size-3.5 sm:size-3"
fill="none"
height="24"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="3"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M5.252 12h13.496" />
</svg>
) : (
<svg
aria-hidden="true"
className="size-3.5 sm:size-3"
fill="none"
height="24"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="3"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M5.252 12.7 10.2 18.63 18.748 5.37" />
</svg>
)}
</span>
)}
/>
</CheckboxPrimitive.Root>
);
}
export { CheckboxPrimitive };
+151
View File
@@ -0,0 +1,151 @@
"use client";
import { mergeProps } from "@base-ui/react/merge-props";
import { useRender } from "@base-ui/react/use-render";
import type React from "react";
import { cn } from "@/lib/utils";
export type TableVariant = "default" | "card";
export type TableProps = React.ComponentProps<"table"> & {
variant?: TableVariant;
render?: useRender.ComponentProps<"div">["render"];
};
export function Table({
className,
variant = "default",
render,
...props
}: TableProps): React.ReactElement {
const defaultProps = {
children: (
<table
className={cn(
"w-full caption-bottom in-data-[variant=card]:border-separate in-data-[variant=card]:border-spacing-0 text-sm",
className,
)}
data-slot="table"
{...props}
/>
),
className: "relative w-full overflow-x-auto",
"data-slot": "table-container",
"data-variant": variant,
};
return useRender({
defaultTagName: "div",
props: mergeProps<"div">(defaultProps, {}),
render,
});
}
export function TableHeader({
className,
...props
}: React.ComponentProps<"thead">): React.ReactElement {
return (
<thead
className={cn("[&_tr]:border-b", className)}
data-slot="table-header"
{...props}
/>
);
}
export function TableBody({
className,
...props
}: React.ComponentProps<"tbody">): React.ReactElement {
return (
<tbody
className={cn(
"relative in-data-[variant=card]:rounded-xl in-data-[variant=card]:shadow-xs/5 before:pointer-events-none before:absolute before:inset-px not-in-data-[variant=card]:before:hidden before:rounded-[calc(var(--radius-xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:before:shadow-[0_-1px_--theme(--color-white/8%)] [&_tr:last-child]:border-0 in-data-[variant=card]:*:[tr]:border-0 in-data-[variant=card]:*:[tr]:*:[td]:border-b in-data-[variant=card]:*:[tr]:*:[td]:bg-card in-data-[variant=card]:*:[tr]:first:*:[td]:first:rounded-ss-xl in-data-[variant=card]:*:[tr]:*:[td]:first:border-s in-data-[variant=card]:*:[tr]:first:*:[td]:border-t in-data-[variant=card]:*:[tr]:last:*:[td]:last:rounded-ee-xl in-data-[variant=card]:*:[tr]:*:[td]:last:border-e in-data-[variant=card]:*:[tr]:first:*:[td]:last:rounded-se-xl in-data-[variant=card]:*:[tr]:last:*:[td]:first:rounded-es-xl in-data-[variant=card]:*:[tr]:hover:*:[td]:bg-[color-mix(in_srgb,var(--card),var(--color-black)_2%)] in-data-[variant=card]:*:[tr]:data-[state=selected]:*:[td]:bg-[color-mix(in_srgb,var(--card),var(--color-black)_4%)] dark:in-data-[variant=card]:*:[tr]:data-[state=selected]:*:[td]:bg-[color-mix(in_srgb,var(--card),var(--color-white)_4%)] dark:in-data-[variant=card]:*:[tr]:hover:*:[td]:bg-[color-mix(in_srgb,var(--card),var(--color-white)_2%)]",
className,
)}
data-slot="table-body"
{...props}
/>
);
}
export function TableFooter({
className,
...props
}: React.ComponentProps<"tfoot">): React.ReactElement {
return (
<tfoot
className={cn(
"border-t in-data-[variant=card]:border-none bg-transparent not-in-data-[variant=card]:bg-[color-mix(in_srgb,var(--card),var(--color-black)_2%)] font-medium dark:not-in-data-[variant=card]:bg-[color-mix(in_srgb,var(--card),var(--color-white)_2%)] [&>tr]:last:border-b-0",
className,
)}
data-slot="table-footer"
{...props}
/>
);
}
export function TableRow({
className,
...props
}: React.ComponentProps<"tr">): React.ReactElement {
return (
<tr
className={cn(
"relative border-b not-in-data-[variant=card]:hover:bg-[color-mix(in_srgb,var(--background),var(--color-black)_2%)] not-in-data-[variant=card]:data-[state=selected]:bg-[color-mix(in_srgb,var(--background),var(--color-black)_4%)] dark:not-in-data-[variant=card]:data-[state=selected]:bg-[color-mix(in_srgb,var(--background),var(--color-white)_4%)] dark:not-in-data-[variant=card]:hover:bg-[color-mix(in_srgb,var(--background),var(--color-white)_2%)]",
className,
)}
data-slot="table-row"
{...props}
/>
);
}
export function TableHead({
className,
...props
}: React.ComponentProps<"th">): React.ReactElement {
return (
<th
className={cn(
"h-10 whitespace-nowrap px-2.5 text-left align-middle font-medium text-muted-foreground leading-none has-[[role=checkbox]]:w-px last:has-[[role=checkbox]]:ps-0 first:has-[[role=checkbox]]:pe-0",
className,
)}
data-slot="table-head"
{...props}
/>
);
}
export function TableCell({
className,
...props
}: React.ComponentProps<"td">): React.ReactElement {
return (
<td
className={cn(
"whitespace-nowrap bg-clip-padding p-2.5 in-data-[slot=table-footer]:py-3.5 align-middle leading-none in-data-[variant=card]:first:ps-[calc(--spacing(2.5)-1px)] in-data-[variant=card]:last:pe-[calc(--spacing(2.5)-1px)] has-[[role=checkbox]]:w-px last:has-[[role=checkbox]]:ps-0 first:has-[[role=checkbox]]:pe-0",
className,
)}
data-slot="table-cell"
{...props}
/>
);
}
export function TableCaption({
className,
...props
}: React.ComponentProps<"caption">): React.ReactElement {
return (
<caption
className={cn(
"in-data-[variant=card]:my-4 mt-4 text-muted-foreground text-sm",
className,
)}
data-slot="table-caption"
{...props}
/>
);
}
@@ -377,7 +377,8 @@
"failedBody": "يرجى المحاولة مرة أخرى."
},
"filterStatus": "تصفية حسب الحالة",
"allStatuses": "كل الحالات"
"allStatuses": "كل الحالات",
"moreActions": "إجراءات إضافية"
},
"appointments": {
"title": "المواعيد والجدول",
@@ -1555,7 +1556,8 @@
"mild": "خفيف",
"moderate": "متوسط",
"severe": "شديد"
}
},
"moreActions": "إجراءات إضافية"
},
"patientForm": {
"editTitle": "تعديل السجل",
@@ -365,7 +365,8 @@
"failedBody": "Bitte versuchen Sie es erneut."
},
"filterStatus": "Nach Status filtern",
"allStatuses": "Alle Status"
"allStatuses": "Alle Status",
"moreActions": "Weitere Aktionen"
},
"appointments": {
"title": "Termine & Zeitplan",
@@ -1535,7 +1536,8 @@
"mild": "Leicht",
"moderate": "Mäßig",
"severe": "Schwer"
}
},
"moreActions": "Weitere Aktionen"
},
"patientForm": {
"editTitle": "Datensatz bearbeiten",
@@ -365,7 +365,8 @@
"failedBody": "Please try again."
},
"filterStatus": "Filter by status",
"allStatuses": "All statuses"
"allStatuses": "All statuses",
"moreActions": "More actions"
},
"appointments": {
"title": "Appointments & Schedule",
@@ -1535,7 +1536,8 @@
"mild": "Mild",
"moderate": "Moderate",
"severe": "Severe"
}
},
"moreActions": "More actions"
},
"patientForm": {
"editTitle": "Edit record",
@@ -365,7 +365,8 @@
"failedBody": "Veuillez réessayer."
},
"filterStatus": "Filtrer par statut",
"allStatuses": "Tous les statuts"
"allStatuses": "Tous les statuts",
"moreActions": "Plus dactions"
},
"appointments": {
"title": "Rendez-vous & Planning",
@@ -1535,7 +1536,8 @@
"mild": "Légère",
"moderate": "Modérée",
"severe": "Sévère"
}
},
"moreActions": "Plus dactions"
},
"patientForm": {
"editTitle": "Modifier le dossier",
@@ -365,7 +365,8 @@
"failedBody": "Fadlan isku day mar kale."
},
"filterStatus": "Ku kala sooc xaaladda",
"allStatuses": "Dhammaan xaaladaha"
"allStatuses": "Dhammaan xaaladaha",
"moreActions": "Ficillo dheeraad ah"
},
"appointments": {
"title": "Ballamaha & Jadwalka",
@@ -1535,7 +1536,8 @@
"mild": "Fudud",
"moderate": "Dhexdhexaad",
"severe": "Daran"
}
},
"moreActions": "Ficillo dheeraad ah"
},
"patientForm": {
"editTitle": "Wax ka beddel diiwaanka",