fix(sharing): keep the document cap literal client-side (no DB import leak)

This commit is contained in:
Marc-André Bombeck committed 2026-07-07 21:25:17 +02:00
1 parent e734c161f4
commit 829345a57b
1 file changed
+10 -3
+10 -3
View File
@@ -62,7 +62,6 @@ import { formatDate, formatDateTime } from "@/lib/format";
import { useTranslations } from "@/lib/i18n/context";
import { queryKeys } from "@/lib/query-keys";
import { apiDelete, apiGet, apiPost } from "@/lib/api/api-fetch";
import { SHARE_LINK_MAX_DOCUMENTS } from "@/lib/validations/clinician-share-link";
/** The FHIR resource types a share link may serve — mirrors C4's enum. */
const RESOURCE_TYPES = [
@@ -77,6 +76,14 @@ type ResourceType = (typeof RESOURCE_TYPES)[number];
const MAX_DAYS = 90;
const DEFAULT_DAYS = 30;
/**
* Maximum documents per share — mirrors `SHARE_LINK_MAX_DOCUMENTS` on the
* server. Kept as a local literal (not imported from the validations module)
* because that module pulls the Prisma client into scope and would drag the DB
* into the client bundle; the server re-enforces the cap on create regardless.
*/
const MAX_DOCUMENTS = 50;
/** Owner-facing shape returned by `GET /api/share-links` (never the token). */
interface ShareLinkSummary {
id: string;
@@ -373,7 +380,7 @@ function ShareLinksCard() {
<p className="text-muted-foreground text-[11px]">
{t("settings.sharing.attachCount", {
count: selectedDocs.length,
max: SHARE_LINK_MAX_DOCUMENTS,
max: MAX_DOCUMENTS,
})}
</p>
</div>
@@ -452,7 +459,7 @@ function ShareLinksCard() {
onOpenChange={setPickerOpen}
selected={selectedDocs}
onSelectedChange={setSelectedDocs}
max={SHARE_LINK_MAX_DOCUMENTS}
max={MAX_DOCUMENTS}
/>
{created && (