"use client"; import { Suspense, useCallback } from "react"; import { ComponentType } from "@prisma/client"; import { Spinner } from "@heroui/spinner"; import { ComponentConfig } from "@/types/shop"; import { COMPONENT_REGISTRY } from "@/lib/registry/component-registry"; interface ConfigurationPanelProps { componentType: ComponentType | null; config: ComponentConfig | null; onUpdateConfig: (newConfig: ComponentConfig) => void; } /** * Configuration panel for editing shop component properties * Uses the component registry for dynamic config panel loading */ export default function ConfigurationPanel({ componentType, config, onUpdateConfig, }: ConfigurationPanelProps) { const updateField = useCallback( ( field: string | number | symbol | Partial, value?: unknown, ) => { let newConfig: ComponentConfig; if (typeof field === "object" && field !== null) { // Handle partial update newConfig = { ...config, ...field } as ComponentConfig; } else { // Handle single field update newConfig = { ...config, [field as string]: value } as ComponentConfig; } onUpdateConfig(newConfig); }, [config, onUpdateConfig], ); if (!componentType || !config) { return (

cấu hình

chọn một thành phần để cấu hình

); } // @ts-ignore - Validated by runtime check or we accept undefined for excluded types const meta = COMPONENT_REGISTRY[componentType as keyof typeof COMPONENT_REGISTRY]; if (!meta) { return (

cấu hình

Loại thành phần không xác định: {componentType}

); } const { ConfigPanel } = meta; return (

cấu hình

} >
); }