import { Link, useSearchParams } from 'react-router-dom'; import { Store, Handshake, Star, Package } from 'lucide-react'; import GearSwapPage from '@/pages/GearSwapPage'; import TradesPage from '@/pages/TradesPage'; import { TradeReputationPanel } from '@/components/TradeReputationPanel'; import { SellerDashboard } from '@/components/SellerDashboard'; import { useCurrentUser } from '@/hooks/useCurrentUser'; import { LoginArea } from '@/components/auth/LoginArea'; import { cn } from '@/lib/utils'; import { useTranslation } from '@/contexts/language'; const TABS = [ { id: 'browse', labelKey: 'marketUi.hub.browse', icon: Store }, { id: 'selling', labelKey: 'marketUi.hub.selling', icon: Package }, { id: 'trades', labelKey: 'marketUi.hub.myTrades', icon: Handshake }, { id: 'reputation', labelKey: 'marketUi.hub.reputation', icon: Star }, ] as const; type TabId = (typeof TABS)[number]['id']; /** * Marketplace hub — one home for buying/selling: the gear grid, your trades and * your reputation/reviews, as tabs. `/trades` and `/listing/...` deep links keep * working; this is just the front door. */ export default function MarketplaceHubPage() { const { t } = useTranslation(); const { user } = useCurrentUser(); // The active tab lives in the URL (?tab=…) so it survives refresh, is // shareable, and works with back/forward. Unknown values fall back to Browse. const [searchParams, setSearchParams] = useSearchParams(); const requested = searchParams.get('tab'); const tab: TabId = (TABS.some((entry) => entry.id === requested) ? requested : 'browse') as TabId; const setTab = (id: TabId) => { const next = new URLSearchParams(searchParams); next.set('tab', id); setSearchParams(next, { replace: true }); }; return ( <> {/* Tab bar — sticky under the app header, like other toolbars. */}
{TABS.map(({ id, labelKey, icon: Icon }) => { const active = tab === id; return ( ); })}
{t('marketTerms.link')}
{tab === 'browse' && } {tab === 'selling' && (
{user ? ( ) : (

{t('marketUi.hub.loginListings')}

)}
)} {tab === 'trades' && } {tab === 'reputation' && (
{user ? ( ) : (

{t('marketUi.hub.loginReputation')}

)}
)} ); }