'use client';
import React from 'react';
import InstantChat from '@/components/Chat/InstantChat';
import { useEstablishment } from '@/context/EstablishmentContext';

export default function MessageriePage() {
  const { user, selectedEstablishmentId } = useEstablishment();

  if (!user?.user_id || !selectedEstablishmentId) {
    return (
      <div className="flex items-center justify-center h-full w-full">
        <div className="text-center">
          <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 mx-auto mb-4"></div>
          <p className="text-gray-600">Chargement de la messagerie...</p>
        </div>
      </div>
    );
  }

  return (
    <div className="h-full flex flex-col">
      <InstantChat
        userProfileId={user.user_id}
        establishmentId={selectedEstablishmentId}
      />
    </div>
  );
}
