"use client"; import { useEffect, useState } from "react"; import { customerPortalUrl } from "@/lib/config"; import { formatFaDate } from "@/lib/format"; import type { CommentItem } from "@/lib/comments"; export function ProductTabs({ descriptionHtml, comments, showDescription = true, }: { descriptionHtml?: string | null; comments: CommentItem[]; showDescription?: boolean; }) { const [tab, setTab] = useState<"description" | "comments">(showDescription ? "description" : "comments"); const [token, setToken] = useState(null); useEffect(() => { setToken( window.localStorage.getItem("accessToken") || window.localStorage.getItem("meshkeeToken") || window.localStorage.getItem("token"), ); }, []); return (
{showDescription ? (
) : (

نظرات

)} {tab === "description" ? ( descriptionHtml ? (
) : (

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

) ) : (
{comments.length === 0 ? (

نظری ثبت نشده است.

) : ( comments.map((comment, index) => (

{comment.authorName || "کاربر"}

{comment.createdAt ?

{formatFaDate(comment.createdAt)}

: null}

{comment.text}

)) )} {token ? (

برای مدیریت نظرات از حساب کاربری خود استفاده کنید.

) : (

برای ثبت نظر وارد شوید

نظرات فقط برای کاربران واردشده فعال است.

ورود / ثبت‌نام
)}
)}
); }