From fedc39a413f6f788fa1afb91874dc3aeea66dd53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Afra=20=E2=80=8C?= Date: Sat, 8 Aug 2026 11:31:58 +0330 Subject: [PATCH] feat: tabs added to profile page --- src/features/auth/authSlice.ts | 1 + src/pages/Profile/Profile.tsx | 12 +++++++++++- src/pages/Profile/ProfileTabs.tsx | 27 ++++++++++++++++++++------- src/utils/storage.ts | 1 + 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/features/auth/authSlice.ts b/src/features/auth/authSlice.ts index e957a16..772ff6d 100644 --- a/src/features/auth/authSlice.ts +++ b/src/features/auth/authSlice.ts @@ -7,6 +7,7 @@ const clearPersistedAuthState = () => { localStorage.removeItem(STORAGE_KEYS.accessToken); localStorage.removeItem(STORAGE_KEYS.user); localStorage.removeItem(STORAGE_KEYS.authState); + localStorage.removeItem(STORAGE_KEYS.lastSearchedUserUuid); clearAuthTokens(); }; diff --git a/src/pages/Profile/Profile.tsx b/src/pages/Profile/Profile.tsx index 221fc61..5b410d6 100644 --- a/src/pages/Profile/Profile.tsx +++ b/src/pages/Profile/Profile.tsx @@ -3,6 +3,7 @@ import { useEffect, useState } from 'react'; import { useSearchParams } from 'react-router-dom'; import { spacing } from '@/design/tokens/spacing'; import { usersApi } from '@/services/usersApi'; +import { STORAGE_KEYS } from '@/utils/storage'; import type { UserDetails } from '@/types/user'; import UserInfoCard from '@/pages/Profile/UserInfoCard'; import StatCardsRow from '@/pages/Profile/StatCards'; @@ -21,7 +22,14 @@ const UUID_PARAM = 'uuid'; const Profile = () => { const { message } = App.useApp(); const [searchParams, setSearchParams] = useSearchParams(); - const uuid = searchParams.get(UUID_PARAM) ?? ''; + const urlUuid = searchParams.get(UUID_PARAM) ?? ''; + // In-app navigation away and back doesn't preserve the URL's query string + // (the sidebar links navigate to bare paths), so fall back to the last + // searched uuid to make that behave like a reload instead of a blank page. + const [fallbackUuid] = useState(() => + urlUuid ? '' : (localStorage.getItem(STORAGE_KEYS.lastSearchedUserUuid) ?? ''), + ); + const uuid = urlUuid || fallbackUuid; const [result, setResult] = useState(null); const handleSearch = (value: string) => { @@ -40,6 +48,8 @@ const Profile = () => { return; } + localStorage.setItem(STORAGE_KEYS.lastSearchedUserUuid, uuid); + usersApi .getUserDetails(uuid) .then((details) => { diff --git a/src/pages/Profile/ProfileTabs.tsx b/src/pages/Profile/ProfileTabs.tsx index cfb10e1..dbcc150 100644 --- a/src/pages/Profile/ProfileTabs.tsx +++ b/src/pages/Profile/ProfileTabs.tsx @@ -5,16 +5,29 @@ interface ProfileTabsProps { style?: CSSProperties; } +const TAB_DEFINITIONS = [ + { key: 'profile', label: 'پروفایل' }, + { key: 'billboards', label: 'بیلبوردها' }, + { key: 'support-tickets', label: 'تیکت‌های پشتیبانی' }, + { key: 'views', label: 'بازدیدها' }, + { key: 'withdrawals', label: 'برداشت‌ها' }, + { key: 'deposits', label: 'واریزها' }, + { key: 'received-promotions', label: 'پروموشن‌های دریافتی' }, + { key: 'comments', label: 'کامنت‌ها' }, + { key: 'invite-friends', label: 'دعوت کردن از دوستان' }, + { key: 'invited-by', label: 'دعوت شده توسط' }, + { key: 'chats', label: 'چت‌ها' }, + { key: 'secure-payment', label: 'پرداخت امن' }, +] as const; + const ProfileTabs = ({ style }: ProfileTabsProps) => ( , - }, - ]} + items={TAB_DEFINITIONS.map(({ key, label }) => ({ + key, + label, + children: , + }))} /> ); diff --git a/src/utils/storage.ts b/src/utils/storage.ts index 450196c..bc687a4 100644 --- a/src/utils/storage.ts +++ b/src/utils/storage.ts @@ -2,4 +2,5 @@ export const STORAGE_KEYS = { accessToken: 'winsoo_access_token', user: 'winsoo_user', authState: 'winsoo_auth_state', + lastSearchedUserUuid: 'winsoo_last_searched_user_uuid', } as const;