"use client"; import { useEffect, useState } from "react"; import { useAuthUser } from "@/lib/auth"; import { customerLoginUrl } from "@/lib/site"; type Tab = "description" | "comments"; type Props = { descriptionHtml?: string; summary?: string; }; export function ProductTabs({ descriptionHtml, summary }: Props) { const [tab, setTab] = useState("description"); const [loginHref, setLoginHref] = useState(customerLoginUrl()); const { user, ready, isLoggedIn } = useAuthUser(); useEffect(() => { const url = new URL(window.location.href); if (url.searchParams.get("tab") === "comments") setTab("comments"); url.searchParams.set("tab", "comments"); setLoginHref(customerLoginUrl(url.toString())); }, []); return (
setTab("description")}> توضیحات setTab("comments")}> نظرات
{tab === "description" ? (
{descriptionHtml ? (
) : summary ? (

{summary}

) : (

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

)}
) : (
{!ready ? (

در حال بررسی ورود...

) : isLoggedIn ? ( ) : (

برای ثبت دیدگاه باید وارد حساب کاربری شوید.

ورود به حساب کاربری
)}
)}
); } function CommentForm({ defaultName }: { defaultName?: string }) { return (
{ event.preventDefault(); }} >