"use client"; import { Lock } from "lucide-react"; import { useTranslation } from "react-i18next"; import { CAPABILITY_LABEL, type Capability } from "@/lib/capability-routes"; import { useCapabilityAccess } from "./CapabilityAccessContext"; /** * Full-surface "this feature is locked" notice. Shown in place of a feature * page when the current user lacks the required model capability. Never hides * the feature — it explains why it is unavailable and what to do. */ export function LockedFeatureNotice({ capability, }: { capability: Capability; }) { const { t } = useTranslation(); const modelLabel = t(CAPABILITY_LABEL[capability]); return (

{t("Feature locked")}

{t( "Your account doesn't have {{model}} assigned yet. Please contact your administrator to get access.", { model: modelLabel }, )}

); } /** * Renders {children} only when the user has the required capability; otherwise * renders the locked notice. Pass capability=null to never gate. */ export function RequireCapability({ capability, children, }: { capability: Capability | null; children: React.ReactNode; }) { const { has } = useCapabilityAccess(); if (capability && !has(capability)) { return ; } return <>{children}; }