/** * Single Product — one of WooCommerce's four store views (see `../index.tsx` * for the top-level hub). Its own four tabs (Summary / Layout / Add-to-Cart * Button / Related & Cross-sells) follow the same hub/tab-section split as * every other family in this app: on the Customizer host each tab is a real * `WP_Customize_Section` of its own (see * Customizer::WOOCOMMERCE_PRODUCT_SUBSECTIONS), reached via `onNavigateTab`. * On the standalone admin page every tab still renders inline. */ import { __ } from '@wordpress/i18n'; import { useEffect, useState } from '@wordpress/element'; import { Package } from 'lucide-react'; import Tabs, { TabPanel } from '../../../controls/tabs'; import type { WorkingSettings, SetPath, SectionExtra } from '../../../types'; import type { WooSchema, Option } from '../types'; import { PRODUCT_TABS } from '../constants'; import { SummaryFields, LayoutFields, CartButtonFields, RelatedFields, } from './fields'; import SectionIntro from '../../../controls/section-intro'; const ID_PREFIX = 'aureon-woocommerce-product'; interface ProductSectionProps { schema: WooSchema; layoutSchema?: { sidebars?: Option[] }; working: WorkingSettings; setPath: SetPath; extras?: SectionExtra[]; onViewChange?: ( context: string ) => void; onNavigateTab?: ( key: string ) => void; /** * See the same prop on `ShopSection` — avoids a duplicate header when * the top hub embeds this inline for the standalone page. */ showHeader?: boolean; } export default function ProductSection( { schema, layoutSchema, working, setPath, extras, onViewChange, onNavigateTab, showHeader = true, }: ProductSectionProps ) { useEffect( () => { onViewChange?.( 'product' ); }, [ onViewChange ] ); const [ activeTab, setActiveTab ] = useState( '' ); const openTab = ( key: string ) => { if ( onNavigateTab ) { onNavigateTab( key ); return; } setActiveTab( key ); }; return (
{ showHeader && (

{ __( 'Single Product', 'aureon' ) }

{ __( 'An individual product page.', 'aureon' ) }

) } { ! onNavigateTab && ( <> ) }
); }