"use client"; import { createPortal } from "react-dom"; import { Lock, X } from "lucide-react"; interface Props { open: boolean; onClose: () => void; /** Short headline above the body, e.g. "Owner-only action". */ title?: string; /** Sentence describing what the user tried to do. */ action?: string; /** Email of the project/resource owner, shown so the user knows who to ask. */ ownerEmail?: string | null; /** Override the default message entirely. */ message?: string; } /** * Lightweight "you don't have permission" modal shown when a non-owner * attempts an owner-only action (manage people, rename, delete, …) on a * shared project. Replaces the silent 404 the backend would otherwise * return so the user understands why the action didn't go through. */ export function OwnerOnlyModal({ open, onClose, title = "Owner-only action", action, ownerEmail, message, }: Props) { if (!open) return null; const body = message ?? (action ? `Only the project owner can ${action}.` : "Only the project owner can perform this action."); return createPortal(
{body}
{ownerEmail && (Ask{" "} {ownerEmail}{" "} if you need access.
)}