"use client";

/**
 * 수주 등록 페이지
 */

import { useRouter } from "next/navigation";
import { OrderRegistration, OrderFormData } from "@/components/orders";
import { toast } from "sonner";

export default function OrderNewPage() {
  const router = useRouter();

  const handleBack = () => {
    router.push("/sales/order-management-sales");
  };

  const handleSave = async (formData: OrderFormData) => {
    // TODO: API 연동
    console.log("수주 등록 데이터:", formData);

    // 임시: 성공 시뮬레이션
    await new Promise((resolve) => setTimeout(resolve, 500));

    toast.success("수주가 등록되었습니다.");
    router.push("/sales/order-management-sales");
  };

  return <OrderRegistration onBack={handleBack} onSave={handleSave} />;
}