"use client";

// 구매관리 > 품의서관리 > 발주서생성 — 양식 선택 모달
// 운영판 wace 1:1 — 일반 / 외주가공 / 영문 / 취소

import React from "react";
import { Dialog, DialogContent, DialogTitle, DialogDescription } from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";

export type PurchaseOrderFormType = "general" | "outsourcing" | "english";

interface Props {
  open: boolean;
  onClose: () => void;
  onSelect: (formType: PurchaseOrderFormType) => void;
}

export function PurchaseOrderFormTypeSelectDialog({ open, onClose, onSelect }: Props) {
  const handlePick = (t: PurchaseOrderFormType) => {
    onSelect(t);
    onClose();
  };

  return (
    <Dialog open={open} onOpenChange={(v) => { if (!v) onClose(); }}>
      <DialogContent className="max-w-[520px] p-0 gap-0 bg-white">
        <DialogTitle className="sr-only">발주서 양식 선택</DialogTitle>
        <DialogDescription className="sr-only">일반, 외주가공, 영문 중 하나를 선택하세요</DialogDescription>
        <div className="px-8 py-10 flex flex-col items-center gap-7">
          <div className="text-[18px] font-semibold">발주서 양식을 선택하세요</div>
          <div className="flex items-center gap-3">
            <Button size="lg" className="h-11 px-7 text-[14px] font-semibold text-white"
                    style={{ background: "#1f7ad6" }}
                    onClick={() => handlePick("general")}>
              일반 발주서
            </Button>
            <Button size="lg" className="h-11 px-7 text-[14px] font-semibold text-white"
                    style={{ background: "#3aa455" }}
                    onClick={() => handlePick("outsourcing")}>
              외주가공 발주서
            </Button>
            <Button size="lg" className="h-11 px-7 text-[14px] font-semibold text-white"
                    style={{ background: "#7146b0" }}
                    onClick={() => handlePick("english")}>
              영문 발주서
            </Button>
          </div>
          <Button size="lg" className="h-10 px-8 text-[14px] font-semibold text-white"
                  style={{ background: "#d64550" }}
                  onClick={onClose}>
            취소
          </Button>
        </div>
      </DialogContent>
    </Dialog>
  );
}
