Add guest cart drawer, Continue handoff, and shared customer login.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-08-25 17:33:39 +03:30
co-authored by Cursor
parent ad05241a77
commit 16340c3b48
18 changed files with 1082 additions and 97 deletions
+6 -18
View File
@@ -1,9 +1,10 @@
"use client";
import { useEffect, useState, type FormEvent } from "react";
import { useState, type FormEvent } from "react";
import type { ApiComment } from "@/lib/api";
import { formatDate } from "@/lib/format";
import { SITE } from "@/lib/site";
import { customerLoginUrl } from "@/lib/customer";
import { useSession } from "@/lib/session";
import { RichContent } from "./RichContent";
type Props = {
@@ -23,26 +24,13 @@ const tabs: Tab[] = [
{ id: "comments", fa: "نظرات", en: "Comments" },
];
function readToken() {
if (typeof window === "undefined") return "";
return (
window.localStorage.getItem("accessToken") ||
window.localStorage.getItem("meshkee_access_token") ||
""
);
}
export function ProductTabs({ productId, descriptionHtml, comments: initialComments }: Props) {
const [tab, setTab] = useState<"description" | "comments">("description");
const [comments, setComments] = useState(initialComments);
const [sent, setSent] = useState(false);
const [sending, setSending] = useState(false);
const [loggedIn, setLoggedIn] = useState(false);
const authorName = "کاربر";
useEffect(() => {
setLoggedIn(Boolean(readToken()));
}, []);
const { isAuthenticated: loggedIn, user } = useSession();
const authorName = user?.firstName?.trim() || "کاربر";
async function onSubmit(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
@@ -157,7 +145,7 @@ export function ProductTabs({ productId, descriptionHtml, comments: initialComme
<div className="rounded-xl bg-zinc-50 px-4 py-5 text-center">
<p className="text-sm text-zinc-600">برای ثبت نظر ابتدا وارد حساب کاربری شوید.</p>
<a
href={SITE.customerUrl}
href={customerLoginUrl("/")}
className="mt-3 inline-block text-sm text-brand"
>
ورود / ثبت نام