"use client"; import { useState } from "react"; import type { EntityComment, TechnicalInfoValue } from "@/lib/types"; type Tab = "description" | "technical" | "reviews"; export default function ProductInfoTabs({ title, descriptionHtml, technicalValues, comments, }: { title: string; descriptionHtml?: string; technicalValues: TechnicalInfoValue[]; comments: EntityComment[]; }) { const [tab, setTab] = useState("description"); const tabs: { key: Tab; label: string }[] = [ { key: "description", label: "توضیحات" }, { key: "technical", label: "مشخصات فنی" }, { key: "reviews", label: `دیدگاه کاربران${comments.length > 0 ? ` (${comments.length})` : ""}` }, ]; return (
{tabs.map((t) => ( ))}
{tab === "description" && (

معرفی {title}

{descriptionHtml ? (
) : (

توضیحی برای این محصول ثبت نشده است.

)}
)} {tab === "technical" && (
{technicalValues.length > 0 ? (
{technicalValues.map((v, i) => (
{v.labelFa || v.label || v.key}
{v.value}
))}
) : (

مشخصات فنی این محصول ثبت نشده است.

)}
)} {tab === "reviews" && (
{comments.length > 0 ? (
    {comments.map((c) => (
  • {c.authorName || "کاربر"} {c.createdAt && ( {c.createdAt.slice(0, 10)} )}
    {c.text &&

    {c.text}

    }
  • ))}
) : (

هنوز دیدگاهی برای این محصول ثبت نشده است.

)}
)}
); }