feat(desktop-header): surface "ورود به فروشگاه من" CTA for sellers and staff

Mobile profile page already has this action, but the desktop chrome had
no way for a seller or staff member to jump into a store they manage —
they'd have to type the URL. Add a compact "فروشگاه من" pill in the
header action row, gated on useMyStores() so it only renders for users
who actually manage a store. Selection mirrors the mobile flow: owned
first, then the first store they staff.
This commit is contained in:
fazli 2026-07-07 10:57:14 +00:00
parent 0d0da636fd
commit 877b01f483

View File

@ -3,6 +3,7 @@ import { useState, useRef, useEffect, type FormEvent } from "react";
import { Search, Heart, ShoppingBag, User, Store } from "lucide-react";
import { useRootData } from "~/hooks/use-root-data";
import { useCartCount } from "~/requestHandler/use-cart-hooks";
import { useMyStores } from "~/requestHandler/use-seller-hooks";
import { useSearchAutocomplete } from "~/requestHandler/use-search-hooks";
import { useDebounce } from "~/hooks/useDebounce";
import { SunMoonToggle } from "~/components/SunMoonToggle";
@ -25,6 +26,12 @@ const DesktopHeader = () => {
const navigate = useNavigate();
const { user, theme } = useRootData();
const cartCount = useCartCount();
const { data: myStores } = useMyStores();
// Mirror the mobile "ورود به فروشگاه من" flow: prefer a store the user owns,
// fall back to the first store they staff. If they don't manage any store,
// the CTA is hidden.
const targetStore =
myStores?.find((s) => s.role === "owner") ?? myStores?.[0];
const [q, setQ] = useState("");
const [open, setOpen] = useState(false);
const searchRef = useRef<HTMLDivElement>(null);
@ -181,6 +188,17 @@ const DesktopHeader = () => {
<SunMoonToggle theme={theme} />
{isLoggedIn ? (
<>
{targetStore ? (
<Link
to={`/store/${targetStore.username}`}
aria-label="ورود به فروشگاه من"
prefetch="intent"
className="inline-flex items-center gap-2 h-[42px] px-3.5 rounded-xl bg-WHITE3 text-BLACK text-[13.5px] font-bold hover:bg-WHITE2 transition-colors whitespace-nowrap"
>
<Store size={18} />
<span>فروشگاه من</span>
</Link>
) : null}
<Link
to="/profile/bookmarks"
aria-label="نشان‌شده‌ها"