'use client';

/**
 * 배차차량관리 - 상세/수정 페이지
 * URL: /outbound/vehicle-dispatches/[id]
 * ?mode=edit로 수정 모드 전환
 */

import { use } from 'react';
import { useSearchParams } from 'next/navigation';
import { VehicleDispatchDetail, VehicleDispatchEdit } from '@/components/outbound/VehicleDispatchManagement';

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

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

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

  return <VehicleDispatchDetail id={id} />;
}
