/** * BoostMedia AI Content Generator Admin - Settings Step (merged: post type + reporter + configure) * * @package BoostMedia_AI * @license GPL-2.0-or-later */ import { useEffect, useState } from 'react' import { Check, ChevronDown, ChevronLeft, ChevronRight } from 'lucide-react' import { Button } from '../common' import { SelectPostTypeContent } from './SelectPostTypeStep' import { SelectReporterContent } from './SelectReporterStep' import { ConfigureContent } from './ConfigureStep' import type { GenerationConfig } from './SelectPostTypeStep' import { t, isRtl } from '../../lib/i18n' type SectionId = 'post-type' | 'reporter' | 'configure' interface SettingsStepProps { config: GenerationConfig onUpdate: (config: GenerationConfig) => void onComplete: () => void } function AccordionSection({ title, isOpen, isComplete, disabled, onToggle, children, }: { title: string isOpen: boolean isComplete: boolean disabled?: boolean onToggle: () => void children: React.ReactNode }) { return (
{isOpen && (
{children}
)}
) } function ConfirmContinueButton({ onClick }: { onClick: () => void }) { const ArrowIcon = isRtl() ? ChevronLeft : ChevronRight return ( ) } export function SettingsStep({ config, onUpdate, onComplete }: SettingsStepProps) { const [openSection, setOpenSection] = useState( config.postType ? (config.reporterId ? 'configure' : 'reporter') : 'post-type' ) const [confirmedPostType, setConfirmedPostType] = useState(Boolean(config.postType)) const [confirmedReporter, setConfirmedReporter] = useState(Boolean(config.reporterId)) useEffect(() => { if (config.postType) setConfirmedPostType(true) }, [config.postType]) useEffect(() => { if (config.reporterId) setConfirmedReporter(true) }, [config.reporterId]) const isPostTypeSelected = Boolean(config.postType) const isReporterSelected = Boolean(config.reporterId) const isConfigComplete = Boolean(config.topic && config.count) const isPostTypeComplete = isPostTypeSelected && confirmedPostType const isReporterComplete = isReporterSelected && confirmedReporter const allComplete = isPostTypeComplete && isReporterComplete && isConfigComplete const handleToggle = (section: SectionId) => { setOpenSection(prev => prev === section ? null : section) } const handleConfirmPostType = () => { setConfirmedPostType(true) setOpenSection('reporter') } const handleConfirmReporter = () => { setConfirmedReporter(true) setOpenSection('configure') } return (
handleToggle('post-type')} > { if (next.postType !== config.postType) { setConfirmedPostType(false) } onUpdate(next) }} /> {isPostTypeSelected && !confirmedPostType && ( )} handleToggle('reporter')} > { if (next.reporterId !== config.reporterId) { setConfirmedReporter(false) } onUpdate(next) }} /> {isReporterSelected && !confirmedReporter && ( )} handleToggle('configure')} >
) }