import { Structure } from "@/payload-types"; import { Item, ItemContent, ItemHeader, ItemTitle, } from "@/components/ui/item"; import { CheckCircleIcon, XCircleIcon, ShieldCheckIcon, ListRestartIcon, } from "lucide-react"; interface StorageRulesProps { allowedStorage: Structure["allowedStorage"]; prohibitedStorage: Structure["prohibitedStorage"]; restrictToAllowed?: Structure["restrictToAllowed"]; } export function StorageRules({ allowedStorage, prohibitedStorage, restrictToAllowed, }: StorageRulesProps) { const hasAllowed = allowedStorage && allowedStorage.length > 0; const hasProhibited = prohibitedStorage && prohibitedStorage.length > 0; if (!hasAllowed && !hasProhibited && !restrictToAllowed) return null; return ( Storage Rules
{restrictToAllowed && (
Whitelist mode — only the items listed under "Allowed" can be stored here. All other items are rejected.
)} {hasAllowed && (
Allowed
{allowedStorage!.map((rule, index) => { if (!rule.item) return null; const item = rule.item; const value = item.value; const name = typeof value === "object" && value !== null && "name" in value ? String(value.name) : `Item #${value}`; return ( {name} {rule.amount && ( ×{rule.amount} )} ); })}
)} {hasProhibited && (
Prohibited
{prohibitedStorage!.map((rule, index) => { if (!rule.item) return null; const item = rule.item; const value = item.value; const name = typeof value === "object" && value !== null && "name" in value ? String(value.name) : `Item #${value}`; return ( {name} ); })}
)}
); }