/** * The screen's pages, by section ID. A page shows when PHP sends its * section (see the wtofe_ai_settings_app_sections filter), e.g. SEO Meta only * while a supported SEO plugin is active; the section's `order` sorts the tabs. */ import type { ComponentType } from 'react'; import { __ } from '@wordpress/i18n'; import ModelsPage from './models/ModelsPage'; import AdvancedPage from './advanced/AdvancedPage'; import ReviewSummaryPage from './review-summary/ReviewSummaryPage'; import SeoMetaPage from './seo-meta/SeoMetaPage'; import ChatbotPage from './chatbot/ChatbotPage'; import type { Section, Sections } from '@/types'; export interface PageProps { section: Section; title: string; } export interface PageInfo { id: string; title: string; } interface PageDefinition { title: () => string; // Each page narrows its section's data; never accepts them all. component: ComponentType>; } export const PAGES: Record = { models: { title: () => __( 'AI Model Selection', 'ai-content-generator-for-woocommerce' ), component: ModelsPage, }, advanced: { title: () => __( 'Advanced Generation Settings', 'ai-content-generator-for-woocommerce' ), component: AdvancedPage, }, 'review-summary': { title: () => __( 'AI Review Summary', 'ai-content-generator-for-woocommerce' ), component: ReviewSummaryPage, }, 'seo-meta': { title: () => __( 'AI SEO Meta', 'ai-content-generator-for-woocommerce' ), component: SeoMetaPage, }, chatbot: { title: () => __( 'Chatbot', 'ai-content-generator-for-woocommerce' ), component: ChatbotPage, }, }; /** The pages PHP sent a section for, in tab order. */ export function availablePages( sections: Sections ): PageInfo[] { return Object.entries( sections ) .filter( ( [ id ] ) => id in PAGES ) .sort( ( [ , a ], [ , b ] ) => a.order - b.order ) .map( ( [ id ] ) => ( { id, title: PAGES[ id ].title() } ) ); }