'use client'

import { redirect } from 'next/navigation'

import { useAuthContext } from '@/contexts/AuthContext'

import { MarketDashboard } from './market-dashboard'

export function WholesaleMarket() {
  const { user } = useAuthContext()

  // Дополнительная защита на уровне компонента
  if (user?.organization?.type !== 'WHOLESALE') {
    console.error('Security violation: wrong role in WholesaleMarket')
    redirect('/login')
  }

  return <MarketDashboard />
}
