'use client';

import { useTranslations } from 'next-intl';
import { useSearchParams } from 'next/navigation';
import { TreatmentWorkspace } from '@/components/ui/treatment/TreatmentWorkspace';
import { useAuth } from '@/lib/hooks/useAuth';

export default function TreatmentPage() {
  const t = useTranslations('treatment');
  const { user, currentOrganization, isAuthReady } = useAuth();
  const searchParams = useSearchParams();
  const initialAppointmentId = searchParams.get('appointmentId');
  const initialLabCaseId = searchParams.get('labCaseId');

  if (!isAuthReady || !user) {
    return (
      <div className="text-sm text-text-muted">{t('loading')}</div>
    );
  }

  return (
    <TreatmentWorkspace
      userId={user.id}
      currentOrganization={currentOrganization}
      initialAppointmentId={initialAppointmentId}
      initialLabCaseId={initialLabCaseId}
    />
  );
}
