'use client';

/**
 * 작업지시 상세 페이지 (Client Component)
 * URL: /production/work-orders/[id]
 * V2 패턴: ?mode=edit로 수정 모드 전환
 */

import { use } from 'react';
import { useSearchParams } from 'next/navigation';
import { WorkOrderDetail, WorkOrderEdit } from '@/components/production/WorkOrders';

interface PageProps {
  params: Promise<{
    id: string;
  }>;
}

export default function WorkOrderDetailPage({ params }: PageProps) {
  const { id } = use(params);
  const searchParams = useSearchParams();
  const mode = searchParams.get('mode');
  const isEditMode = mode === 'edit';

  if (isEditMode) {
    return <WorkOrderEdit orderId={id} />;
  }

  return <WorkOrderDetail orderId={id} />;
}