/** * The Product Catalog settings that are reached from WooCommerce's own panel * directly rather than by drilling into Product Catalog — Sale Badge and Sale * Price (see `Customizer::WOOCOMMERCE_SETTING_SECTIONS`). * * Each renders the very same field group it used to render inside Product * Catalog's General tab; only where it is reached from changed. One component * covers both because that is genuinely all they differ by — an icon, a * title, a line of description, and which field group to render. */ import { __ } from '@wordpress/i18n'; import { Tag, Percent } from 'lucide-react'; import type { LucideIcon } from 'lucide-react'; import type { WorkingSettings, SetPath, SectionExtra } from '../../types'; import type { WooSchema } from './types'; import { SaleBadgeFields } from './shop/sale-badge'; import { SalePriceFields } from './shop/sale-price'; import { ExtrasFields } from './shared'; import SectionIntro from '../../controls/section-intro'; export type SettingSectionKey = 'sale_badge' | 'sale_price'; interface SettingSectionProps { sectionKey: SettingSectionKey; schema: WooSchema; working: WorkingSettings; setPath: SetPath; extras?: SectionExtra[]; /** * Point the preview at the view a field actually shows up in — the same * hook the workspace view switchers use (`onViewChange`). Sale Badge is * the one section here that edits two views at once: its shop-wide fields * read on the product grid, its Product page fields only on a product * page, where the grid preview shows nothing at all. */ onPreviewContext?: ( context: string ) => void; } const HEADERS: Record< SettingSectionKey, { icon: LucideIcon; title: string; description: string } > = { sale_badge: { icon: Tag, get title() { return __( 'Sale Badge', 'aureon' ); }, get description() { return __( 'Control the sale badge text, style, position and colors.', 'aureon' ); }, }, sale_price: { icon: Percent, get title() { return __( 'Sale Price', 'aureon' ); }, get description() { return __( 'Customize how sale prices look across your store.', 'aureon' ); }, }, }; export default function SettingSection( { sectionKey, schema, working, setPath, extras, onPreviewContext, }: SettingSectionProps ) { const header = HEADERS[ sectionKey ]; const Icon = header.icon; return (

{ header.title }

{ header.description }

{ 'sale_badge' === sectionKey && ( ) } { 'sale_price' === sectionKey && ( ) }
); }