import { summaryRegistry } from '../utils/summary-functions'; import { __ } from '@wordpress/i18n'; /** * Renders the summary for a collapsed section. * It acts as a dispatcher, calling the correct summary function * based on the 'summary_callback' defined in the section's data. */ const SummaryRenderer = ({ section, allMetaData, entityData, i18n, availableConditions }) => { // Get the name of the summary function from the section's "blueprint" const callbackName = section.summary_callback; // Find the actual function in our registry const summaryFunction = summaryRegistry[callbackName]; // If a function is found, call it with all the necessary data if (typeof summaryFunction === 'function') { const summaryText = summaryFunction(section, allMetaData, entityData, i18n, availableConditions); // Render the result, or nothing if the function returns an empty string return <>{summaryText || ''}; } // Render a fallback message if no summary function is defined for this section return {__('No summary available.', 'adpresso')}; }; export default SummaryRenderer;