import { SemanticMetrics } from '../../lib/types';
import MetricCard from './Metriccard';
import SectionTitle from './SectionTitle';

export default function TextAnalysis({
  semantic,
}: {
  semantic?: SemanticMetrics;
}) {
  if (semantic === undefined) {
    return <p>Ma&apos;lumot topilmadi</p>;
  }
  return (
    <>
      <SectionTitle>Matn tahlili</SectionTitle>
      <div className="grid grid-cols-3 gap-2">
        <MetricCard
          label="Jami so'z"
          value={semantic.totalWords.toLocaleString()}
        />
        <MetricCard
          label="Unikal so'z"
          value={semantic.uniqueWords.toLocaleString()}
        />
        <MetricCard
          label="Leksik unikalligi"
          value={`${semantic.lexicalUniqueness.toFixed(1)}%`}
        />
        <MetricCard label="Jumlalar" value={String(semantic.sentences)} />
        <MetricCard
          label="O'rt. so'z/juml."
          value={semantic.avgWordsPerSentence.toFixed(1)}
        />
        <MetricCard label="Qatorlar" value={String(semantic.lines)} />
      </div>
    </>
  );
}
