import { __, sprintf } from '@/wp-externals/i18n'; import { cn } from '@/lib/utils'; import { normalizeRecommendations } from '@/components/readiness-recommendations-list'; import type { VisibilityDetails } from './use-visibility-data'; /** * Diagnostics checklist for the editor sidebar (adoption plan F2.2): * the same content-quality sub-components the drawer shows, rendered as * passed / partial / missing rows with the points each item is worth * (component weight x the 30% content-quality share of the total score). */ interface ChecklistItemDef { key: string; label: string; /** Max contribution to the total 0-100 score (weight x 30). */ points: number; } function pageItems(): ChecklistItemDef[] { return [ { key: 'content_length', label: __('Content length', 'llmagnet-llm-txt-generator'), points: 6 }, { key: 'heading_structure', label: __('Heading structure', 'llmagnet-llm-txt-generator'), points: 6 }, { key: 'alt_coverage', label: __('Image ALT coverage', 'llmagnet-llm-txt-generator'), points: 6 }, { key: 'excerpt_quality', label: __('Excerpt', 'llmagnet-llm-txt-generator'), points: 4.5 }, { key: 'tags_categories', label: __('Tags & categories', 'llmagnet-llm-txt-generator'), points: 4.5 }, { key: 'readability', label: __('Readability', 'llmagnet-llm-txt-generator'), points: 3 }, ]; } function productItems(): ChecklistItemDef[] { return [ { key: 'description_length', label: __('Description length', 'llmagnet-llm-txt-generator'), points: 10.5 }, { key: 'tags_count', label: __('Tags', 'llmagnet-llm-txt-generator'), points: 6 }, { key: 'category_assignment', label: __('Category assigned', 'llmagnet-llm-txt-generator'), points: 4.5 }, { key: 'alt_coverage', label: __('Image ALT coverage', 'llmagnet-llm-txt-generator'), points: 9 }, ]; } function StatusIcon({ value }: { value: number }) { if (value >= 80) { return ( ✓ ); } if (value >= 50) { return ( ~ ); } return ( ✗ ); } export interface DiagnosticsChecklistProps { details: VisibilityDetails; postType: string; className?: string; } export function DiagnosticsChecklist({ details, postType, className }: DiagnosticsChecklistProps) { const components = details.content_quality?.components ?? {}; const items = (postType === 'product' ? productItems() : pageItems()).filter( (item) => typeof components[item.key] === 'number' ); const botScore = details.bot_visibility?.score; const recommendations = normalizeRecommendations(details.recommendations); return (
{typeof botScore === 'number' && (
{__('AI bot visibility (70% of score)', 'llmagnet-llm-txt-generator')} {Math.round(botScore)}/100
)} {items.length > 0 && ( )} {recommendations.length > 0 && (

{__('Recommendations', 'llmagnet-llm-txt-generator')}

)}
); }