'use client'

import { redirect } from 'next/navigation'

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

import { MessengerDashboard } from './messenger-dashboard'

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

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

  return <MessengerDashboard />
}
