'use client'

import { redirect } from 'next/navigation'

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

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

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

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

  return <MessengerDashboard />
}
