diff --git a/app/routes/profile._index.tsx b/app/routes/profile._index.tsx index 59f12ce..2c3550d 100644 --- a/app/routes/profile._index.tsx +++ b/app/routes/profile._index.tsx @@ -15,9 +15,11 @@ import { CircleUserRound, FileQuestion, Layers, + Pencil, } from "lucide-react"; import { Link, useNavigate } from "@remix-run/react"; import { useServiceGetProfile } from "~/utils/RequestHandler"; +import { useServiceGetWallet } from "~/requestHandler/use-wallet-hooks"; import { Skeleton } from "~/components/ui/skeleton"; import { useState } from "react"; import { Button } from "~/components/ui/button"; @@ -53,12 +55,53 @@ export default function Profile() { const [loginModalOpen, setLoginModalOpen] = useState(false); const [logoutModalOpen, setLogoutModalOpen] = useState(false); const { data: profileData } = useServiceGetProfile(); + const { data: walletData } = useServiceGetWallet(); const { data: followedSellers, isLoading: isFollowedSellersLoading } = useServiceGetFollowedSellers(); // Calculate the count of followed sellers const followedCount = followedSellers?.length || 0; + const walletBalance = walletData?.balance + ? new Intl.NumberFormat("fa-IR").format(parseInt(walletData.balance)) + : "۰"; + + // Top quick-actions (also live in the menu, but surfaced as a grid) + const quickActions = [ + { + label: "سفارش‌ها", + link: "/profile/orders", + icon: , + badge: null as number | null, + }, + { + label: "نشان‌ها", + link: "/profile/bookmarks", + icon: , + badge: null, + }, + { + label: "دنبال‌ها", + link: "/profile/following", + icon: , + badge: followedCount || null, + }, + { + label: "آدرس‌ها", + link: "/profile/location", + icon: , + badge: null, + }, + ]; + // The menu list below drops the items surfaced as quick actions / wallet card. + const quickPages = new Set([ + "orders", + "bookmarks", + "following", + "location", + "wallet", + ]); + // Create dynamic items with the followed count const menuItems: MenuItemType[] = [ { @@ -147,36 +190,95 @@ export default function Profile() {

یک گزینه را از منوی کناری انتخاب کنید

- {/* Mobile: account menu */} + {/* Mobile: account hub */}
- -
-
-

+ {/* Header: avatar + name + phone + edit */} +

+ +
+

+ {profileData?.username || "کاربر ویترون"} +

+ {profileData?.phoneNumber ? ( +

+ {profileData.phoneNumber} +

+ ) : null} +
+ + + +
+ + {/* Wallet card */} + +
+ موجودی کیف پول + + {walletBalance} + تومان + +
+ + افزایش موجودی + + + + {/* Quick actions */} +
+ {quickActions.map((qa) => ( + +
+ {qa.badge ? ( + + {qa.badge} + + ) : null} + {qa.icon} +
+ {qa.label} + + ))} +
+ +

حساب من

+ + {/* Theme toggle */} +
+

{initialTheme === "dark" ? "حالت تاریک" : "حالت روشن"}

+
- -
- { - if (profileData?.sellerUsername) { - navigate(`/store/${profileData.sellerUsername}`); - } else { - if (user?.access_token) { - setStoreModalOpen(true); + + !quickPages.has(m.pageName))} + onStoreClick={() => { + if (profileData?.sellerUsername) { + navigate(`/store/${profileData.sellerUsername}`); } else { - setLoginModalOpen(true); + if (user?.access_token) { + setStoreModalOpen(true); + } else { + setLoginModalOpen(true); + } } - } - }} - onLogoutClick={() => { - setLogoutModalOpen(true); - }} - /> + }} + onLogoutClick={() => { + setLogoutModalOpen(true); + }} + />