/** * My Account — one of WooCommerce's store views (see `../index.tsx` for the * top-level hub). Its two tabs (Account / Login) are the signed-in and * signed-out halves of the same page, not separate topics, so — like Cart and * Checkout — both render inline behind one segmented toggle rather than each * drilling into a `WP_Customize_Section` of its own. Both hosts therefore * render exactly the same thing here. * * The tabs move the preview between them. Whoever is editing is signed in, so * the account page renders the dashboard and the Login tab would otherwise * describe a screen the iframe cannot show; switching to it asks for the * `account_login` preview URL, which renders the signed-out template for a * verified preview request (see `WooCommerce::maybe_preview_login_screen()`). */ import { __ } from '@wordpress/i18n'; import { useEffect, useState } from '@wordpress/element'; import { UserRound } from 'lucide-react'; import Tabs, { TabPanel } from '../../../controls/tabs'; import type { WorkingSettings, SetPath } from '../../../types'; import type { WooSchema } from '../types'; import { ACCOUNT_TABS } from '../constants'; import { AccountLayoutFields, AccountLoginFields } from './fields'; import SectionIntro from '../../../controls/section-intro'; const ID_PREFIX = 'aureon-woocommerce-account'; interface AccountSectionProps { schema: WooSchema; working: WorkingSettings; setPath: SetPath; onViewChange?: ( context: string ) => void; /** * Point the preview at a named context. Distinct from `onViewChange`, * which reports *which view* is open for the shell's own bookkeeping; * this moves the iframe, and the two tabs here show two different pages. */ onPreviewContext?: ( context: string ) => void; /** * See the same prop on `CartSection` — avoids a duplicate header when * the top hub embeds this inline for the standalone page. */ showHeader?: boolean; } export default function AccountSection( { schema, working, setPath, onViewChange, onPreviewContext, showHeader = true, }: AccountSectionProps ) { useEffect( () => { onViewChange?.( 'account' ); }, [ onViewChange ] ); const [ activeTab, setActiveTab ] = useState( 'layout' ); // Keep the preview on whichever half is open — including on first mount, // so opening the section straight onto a remembered tab still lands the // iframe on the matching screen. useEffect( () => { onPreviewContext?.( 'login' === activeTab ? 'account_login' : 'account' ); }, [ activeTab, onPreviewContext ] ); return (
{ showHeader && (

{ __( 'My Account', 'aureon' ) }

{ __( 'Customize the customer account area and the screen visitors sign in on.', 'aureon' ) }

) }
); }