import React from 'react'; import { CheckCircle2Icon, CircleAlertIcon, GlobeIcon, KeyIcon, SearchCheckIcon, TextIcon } from 'lucide-react'; import { SurfaceCard } from './ui/SurfaceCard'; import { TextField } from './ui/TextField'; import { TextArea } from './ui/TextArea'; export interface SeoState { focusKeyword: string; seoTitle: string; metaDescription: string; slug: string; } interface SeoPanelProps { value: SeoState; onChange: (value: SeoState) => void; } interface Check { label: string; passed: boolean; } export function SeoPanel({ value, onChange }: SeoPanelProps) { const set = (key: keyof SeoState, next: string) => onChange({ ...value, [key]: next }); const checks: Check[] = [ { label: 'کلمه کلیدی در عنوان سئو آمده است', passed: Boolean(value.focusKeyword) && value.seoTitle.includes(value.focusKeyword) }, { label: 'طول عنوان سئو بین ۳۰ تا ۶۰ نویسه است', passed: value.seoTitle.length >= 30 && value.seoTitle.length <= 60 }, { label: 'توضیح متا بین ۷۰ تا ۱۶۰ نویسه است', passed: value.metaDescription.length >= 70 && value.metaDescription.length <= 160 }, { label: 'کلمه کلیدی در توضیح متا آمده است', passed: Boolean(value.focusKeyword) && value.metaDescription.includes(value.focusKeyword) }, { label: 'نامک (Slug) کوتاه و خواناست', passed: value.slug.length > 0 && value.slug.length <= 60 }]; const passedCount = checks.filter((check) => check.passed).length; const score = Math.round(passedCount / checks.length * 100); const scoreLabel = score >= 80 ? 'عالی' : score >= 50 ? 'قابل بهبود' : 'ضعیف'; return ( = 80 ? 'bg-copper text-[#241a11]' : 'bg-copper-soft text-copper'}` }> امتیاز سئو: {score} — {scoreLabel} }>
set('focusKeyword', event.target.value)} placeholder="سرمایه‌گذاری ملکی" /> set('seoTitle', event.target.value)} hint={`${value.seoTitle.length} از ۶۰ نویسه`} /> set('slug', event.target.value)} placeholder="real-estate-investment-guide" />