fix(profile): prevent horizontal overflow and fix mobile layout in UserDashboard

This commit is contained in:
parsa aghaei committed 2026-07-25 11:49:53 +03:30
1 parent 68fbd7d183
commit 16ccd99010
1 file changed
+29 -29
@@ -139,36 +139,36 @@ export default function UserDashboard() {
];
return (
<div className="min-h-screen bg-medical-gray-50 pt-12 pb-24 px-4 font-vazir" dir="rtl">
<div className="max-w-6xl mx-auto">
<div className="min-h-screen bg-medical-gray-50 pt-6 sm:pt-12 pb-24 px-3 sm:px-4 font-vazir overflow-x-hidden" dir="rtl">
<div className="max-w-6xl mx-auto w-full">
{/* Breadcrumb */}
<div className="flex items-center gap-2 text-[10px] font-black text-medical-gray-400 uppercase tracking-widest mb-10 overflow-x-auto whitespace-nowrap pb-2">
<div className="flex items-center gap-2 text-[10px] font-black text-medical-gray-400 uppercase tracking-widest mb-6 sm:mb-10 overflow-x-auto whitespace-nowrap pb-2 no-scrollbar">
<span className="cursor-pointer hover:text-canina-blue" onClick={() => router.push('/')}>خانه</span>
<ChevronRight className="w-2.5 h-2.5 flex-shrink-0" />
<span className="text-canina-blue">پنل کاربری</span>
</div>
<div className="grid lg:grid-cols-12 gap-8">
<div className="grid lg:grid-cols-12 gap-6 sm:gap-8">
{/* Sidebar */}
<div className="lg:col-span-4 space-y-6">
<div className="bg-white rounded-[2rem] sm:rounded-[3rem] border border-medical-gray-200 p-6 sm:p-8 shadow-xl">
<div className="flex items-center gap-4 mb-8 sm:mb-10">
<div className="w-14 h-14 sm:w-16 sm:h-16 bg-canina-blue rounded-2xl sm:rounded-3xl flex items-center justify-center text-white shadow-lg flex-shrink-0">
<User className="w-7 h-7 sm:w-8 sm:h-8" />
<div className="lg:col-span-4 space-y-4 sm:space-y-6 min-w-0">
<div className="bg-white rounded-[1.5rem] sm:rounded-[3rem] border border-medical-gray-200 p-4 sm:p-8 shadow-xl">
<div className="flex items-center gap-3 sm:gap-4 mb-6 sm:mb-10">
<div className="w-12 h-12 sm:w-16 sm:h-16 bg-canina-blue rounded-xl sm:rounded-3xl flex items-center justify-center text-white shadow-lg flex-shrink-0">
<User className="w-6 h-6 sm:w-8 sm:h-8" />
</div>
<div className="min-w-0">
<h2 className="text-lg sm:text-xl font-black text-medical-gray-900 truncate">{profile.firstName} {profile.lastName}</h2>
<p className="text-xs sm:text-sm font-bold text-medical-gray-400 truncate">{profile.email}</p>
<div className="min-w-0 flex-1">
<h2 className="text-base sm:text-xl font-black text-medical-gray-900 truncate">{profile.firstName} {profile.lastName}</h2>
<p className="text-[11px] sm:text-sm font-bold text-medical-gray-400 truncate">{profile.email}</p>
</div>
</div>
{/* Responsive Tab Bar: Horizontal Scroll on Mobile, Vertical Stack on Desktop */}
<div className="flex lg:flex-col gap-2 overflow-x-auto lg:overflow-x-visible pb-3 lg:pb-0 whitespace-nowrap">
<div className="flex lg:flex-col gap-2 overflow-x-auto lg:overflow-x-visible pb-2 lg:pb-0 whitespace-nowrap no-scrollbar -mx-2 px-2 lg:mx-0 lg:px-0">
{tabs.map(tab => (
<button
key={tab.id}
onClick={() => setActiveTab(tab.id as any)}
className={`flex items-center gap-2.5 px-4 py-3 sm:py-4 rounded-xl sm:rounded-2xl transition-all font-bold text-xs sm:text-sm flex-shrink-0 ${activeTab === tab.id ? "bg-canina-blue text-white shadow-lg shadow-canina-blue/20" : "text-medical-gray-600 hover:bg-medical-gray-50 bg-medical-gray-50/50 lg:bg-transparent"}`}
className={`flex items-center gap-2 px-3 sm:px-4 py-2.5 sm:py-4 rounded-xl sm:rounded-2xl transition-all font-bold text-xs sm:text-sm flex-shrink-0 ${activeTab === tab.id ? "bg-canina-blue text-white shadow-lg shadow-canina-blue/20" : "text-medical-gray-600 hover:bg-medical-gray-50 bg-medical-gray-50/50 lg:bg-transparent"}`}
>
<div className="flex-shrink-0">{tab.icon}</div>
<span>{tab.label}</span>
@@ -176,7 +176,7 @@ export default function UserDashboard() {
))}
<button
onClick={handleLogout}
className="flex items-center gap-2.5 px-4 py-3 sm:py-4 rounded-xl sm:rounded-2xl text-red-500 hover:bg-red-50 transition-all font-bold text-xs sm:text-sm flex-shrink-0 lg:mt-4 bg-red-50/30 lg:bg-transparent"
className="flex items-center gap-2 px-3 sm:px-4 py-2.5 sm:py-4 rounded-xl sm:rounded-2xl text-red-500 hover:bg-red-50 transition-all font-bold text-xs sm:text-sm flex-shrink-0 lg:mt-4 bg-red-50/30 lg:bg-transparent"
>
<LogOut className="w-4 h-4 sm:w-5 sm:h-5 flex-shrink-0" />
<span>خروج</span>
@@ -184,47 +184,47 @@ export default function UserDashboard() {
</div>
</div>
<div className="bg-medical-gray-900 rounded-[2rem] sm:rounded-[3rem] p-6 sm:p-8 text-white relative overflow-hidden shadow-2xl">
<div className="absolute top-0 left-0 p-6 opacity-20">
<div className="bg-medical-gray-900 rounded-[1.5rem] sm:rounded-[3rem] p-5 sm:p-8 text-white relative overflow-hidden shadow-2xl">
<div className="absolute top-0 left-0 p-6 opacity-20 pointer-events-none">
<Wallet className="w-12 h-12 text-canina-blue" />
</div>
<div className="relative z-10">
<div className="text-[10px] font-black uppercase tracking-widest text-white/70 mb-2">موجودی کیف پول</div>
<div className="flex items-baseline gap-2 flex-row-reverse justify-end">
<div className="text-3xl sm:text-4xl font-black italic">{toPersian((profile.walletBalance ?? 0).toLocaleString())}</div>
<div className="text-2xl sm:text-4xl font-black italic">{toPersian((profile.walletBalance ?? 0).toLocaleString())}</div>
<span className="text-xs sm:text-sm not-italic font-bold text-white/80">تومان</span>
</div>
<button
onClick={() => { setActiveTab("wallet"); setIsTopUpModalOpen(true); }}
disabled={isTopUpModalOpen}
className="mt-6 sm:mt-8 bg-canina-blue w-full py-3.5 sm:py-4 rounded-xl sm:rounded-2xl font-black hover:bg-white hover:text-canina-blue transition-all shadow-lg shadow-black/20 flex items-center justify-center gap-2 text-xs sm:text-sm"
className="mt-5 sm:mt-8 bg-canina-blue w-full py-3 sm:py-4 rounded-xl sm:rounded-2xl font-black hover:bg-white hover:text-canina-blue transition-all shadow-lg shadow-black/20 flex items-center justify-center gap-2 text-xs sm:text-sm"
>
شارژ کیف پول
</button>
</div>
</div>
<div className="bg-pink-500 rounded-[2rem] sm:rounded-[3rem] p-6 sm:p-8 text-white relative overflow-hidden shadow-2xl shadow-pink-200">
<div className="absolute -top-4 -right-4 opacity-10">
<div className="bg-pink-500 rounded-[1.5rem] sm:rounded-[3rem] p-5 sm:p-8 text-white relative overflow-hidden shadow-2xl shadow-pink-200">
<div className="absolute -top-4 -right-4 opacity-10 pointer-events-none">
<Heart className="w-32 sm:w-40 h-32 sm:h-40 fill-white" />
</div>
<div className="relative z-10">
<div className="flex items-center gap-3 mb-4 sm:mb-6">
<Heart className="w-5 h-5 fill-white flex-shrink-0" />
<div className="flex items-center gap-2 sm:gap-3 mb-4 sm:mb-6">
<Heart className="w-4 h-4 sm:w-5 sm:h-5 fill-white flex-shrink-0" />
<h4 className="text-xs sm:text-sm font-black italic tracking-widest">ردپای مهربانی</h4>
</div>
<div className="space-y-4 sm:space-y-6">
<div>
<p className="text-[10px] font-bold text-white/70 mb-1">مجموع کمک‌های اهدایی</p>
<div className="flex items-baseline gap-2 flex-row-reverse justify-end">
<span className="text-2xl sm:text-3xl font-black italic">{toPersian(profile.charityDonationTotal?.toLocaleString() || "0")}</span>
<span className="text-xl sm:text-3xl font-black italic">{toPersian(profile.charityDonationTotal?.toLocaleString() || "0")}</span>
<span className="text-xs font-bold opacity-60">تومان</span>
</div>
</div>
<div className="p-3 sm:p-4 bg-white/10 rounded-xl sm:rounded-2xl border border-white/20 backdrop-blur-sm">
<div className="flex items-start gap-3">
<div className="w-7 h-7 sm:w-8 sm:h-8 bg-white/20 rounded-lg sm:rounded-xl flex items-center justify-center flex-shrink-0 mt-0.5">
<Sparkles className="w-3.5 h-3.5 sm:w-4 sm:h-4 text-white" />
<div className="flex items-start gap-2.5 sm:gap-3">
<div className="w-6 h-6 sm:w-8 sm:h-8 bg-white/20 rounded-lg sm:rounded-xl flex items-center justify-center flex-shrink-0 mt-0.5">
<Sparkles className="w-3 h-3 sm:w-4 sm:h-4 text-white" />
</div>
<p className="text-[10px] sm:text-xs font-black leading-relaxed">
همکاری شما باعث تامین هزینه <span className="text-xs sm:text-sm text-yellow-300 mx-1">{toPersian(Math.floor((profile.charityDonationTotal || 0) / 15000).toString())} وعده غذا</span> برای حیوانات بی‌پناه شده است.
@@ -237,12 +237,12 @@ export default function UserDashboard() {
</div>
{/* Main Content */}
<div className="lg:col-span-8">
<div className="lg:col-span-8 min-w-0">
<motion.div
key={activeTab}
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
className="bg-white rounded-[2rem] sm:rounded-[3.5rem] border border-medical-gray-200 p-5 sm:p-10 min-h-[500px] sm:min-h-[600px] shadow-sm overflow-hidden"
className="bg-white rounded-[1.5rem] sm:rounded-[3.5rem] border border-medical-gray-200 p-4 sm:p-10 min-h-[400px] sm:min-h-[600px] shadow-sm overflow-hidden"
>
{activeTab === "profile" && (
<div>