/** * Article Preview - read-only view of a generated article. */ import { useState, useEffect } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { Button } from '@aime/wp-components'; import { chevronLeft, edit } from '@wordpress/icons'; import useApi from '../../../hooks/useApi'; import Card from '../../common/Card'; import Loader from '../../common/Loader'; import { ARTICLE_STATUS_LABELS, ARTICLE_STATUS_COLORS } from '../../../utils/constants'; import sanitizeHtml from '../../../utils/sanitizeHtml'; const ArticlePreview = ( { id, onBack, onNavigate } ) => { const { get, loading } = useApi(); const [ article, setArticle ] = useState( null ); useEffect( () => { if ( ! id ) return; const load = async () => { try { const res = await get( `/content/articles/${ id }` ); setArticle( res ); } catch ( e ) { // silent } }; load(); }, [ get, id ] ); if ( loading || ! article ) { return ; } const keywords = Array.isArray( article.keywords ) ? article.keywords : []; return (

{ __( 'Article Preview', 'ai-marketing-expert' ) }

{ ARTICLE_STATUS_LABELS[ article.status ] || article.status } { article.tone && { article.tone } } { article.language && { article.language } } { article.actual_word_count > 0 && ( { article.actual_word_count } { __( 'words', 'ai-marketing-expert' ) } ) }

{ article.title || __( 'Untitled', 'ai-marketing-expert' ) }

{ article.excerpt && (

{ article.excerpt }

) } { keywords.length > 0 && (
{ keywords.map( ( kw, i ) => ( { kw } ) ) }
) }
No content yet.

' } } />
{ /* Scores */ }
{ __( 'SEO Score', 'ai-marketing-expert' ) } = 70 ? 'aime-score-good' : article.seo_score >= 40 ? 'aime-score-ok' : 'aime-score-bad' }> { article.seo_score || 0 } / 100
{ __( 'Readability', 'ai-marketing-expert' ) } = 60 ? 'aime-score-good' : article.readability_score >= 30 ? 'aime-score-ok' : 'aime-score-bad' }> { article.readability_score || 0 } / 100
{ /* SEO Meta */ } { ( article.meta_title || article.meta_description ) && ( { article.meta_title && (

{ article.meta_title }

) } { article.meta_description && (

{ article.meta_description }

) }
) } { /* History */ } { article.history?.length > 0 && (
{ article.history.map( ( h, i ) => (
{ h.action } { h.created_at } { h.details &&

{ h.details }

}
) ) }
) } { /* WordPress link */ } { article.wp_post_id && (

{ __( 'Post ID:', 'ai-marketing-expert' ) } { article.wp_post_id }

) }
); }; export default ArticlePreview;