diff options
Diffstat (limited to 'lib/basic-contract/template/add-basic-contract-template-dialog.tsx')
| -rw-r--r-- | lib/basic-contract/template/add-basic-contract-template-dialog.tsx | 96 |
1 files changed, 52 insertions, 44 deletions
diff --git a/lib/basic-contract/template/add-basic-contract-template-dialog.tsx b/lib/basic-contract/template/add-basic-contract-template-dialog.tsx index c88819e4..9b036445 100644 --- a/lib/basic-contract/template/add-basic-contract-template-dialog.tsx +++ b/lib/basic-contract/template/add-basic-contract-template-dialog.tsx @@ -41,13 +41,26 @@ import { Separator } from "@/components/ui/separator"; import { useRouter } from "next/navigation";
import { BUSINESS_UNITS } from "@/config/basicContractColumnsConfig";
-// 업데이트된 계약서 템플릿 스키마 정의
+// 템플릿 이름 옵션 정의
+const TEMPLATE_NAME_OPTIONS = [
+ "준법서약",
+ "기술자료 요구서",
+ "비밀유지 계약서",
+ "표준하도급기본 계약서",
+ "General GTC",
+ "안전보건관리 약정서",
+ "동반성장",
+ "윤리규범 준수 서약서",
+ "기술자료 동의서",
+ "내국신용장 미개설 합의서",
+ "직납자재 하도급대급등 연동제 의향서"
+] as const;
+
+// 업데이트된 계약서 템플릿 스키마 정의 (워드파일만 허용)
const templateFormSchema = z.object({
- templateCode: z.string()
- .min(1, "템플릿 코드는 필수입니다.")
- .max(50, "템플릿 코드는 50자 이하여야 합니다.")
- .regex(/^[A-Z0-9_-]+$/, "템플릿 코드는 영문 대문자, 숫자, '_', '-'만 사용 가능합니다."),
- templateName: z.string().min(1, "템플릿 이름은 필수입니다."),
+ templateName: z.enum(TEMPLATE_NAME_OPTIONS, {
+ required_error: "템플릿 이름을 선택해주세요.",
+ }),
revision: z.coerce.number().int().min(1).default(1),
legalReviewRequired: z.boolean().default(false),
@@ -67,8 +80,10 @@ const templateFormSchema = z.object({ message: "파일 크기는 100MB 이하여야 합니다.",
})
.refine(
- (file) => file.type === 'application/pdf',
- { message: "PDF 파일만 업로드 가능합니다." }
+ (file) =>
+ file.type === 'application/msword' ||
+ file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+ { message: "워드 파일(.doc, .docx)만 업로드 가능합니다." }
),
status: z.enum(["ACTIVE", "DISPOSED"]).default("ACTIVE"),
}).refine((data) => {
@@ -95,10 +110,9 @@ export function AddTemplateDialog() { const [showProgress, setShowProgress] = React.useState(false);
const router = useRouter();
- // 기본값 설정
+ // 기본값 설정 (templateCode 제거)
const defaultValues: Partial<TemplateFormValues> = {
- templateCode: "",
- templateName: "",
+ templateName: undefined,
revision: 1,
legalReviewRequired: false,
shipBuildingApplicable: false,
@@ -183,7 +197,7 @@ export function AddTemplateDialog() { }
};
- // 폼 제출 핸들러
+ // 폼 제출 핸들러 (templateCode 제거)
async function onSubmit(formData: TemplateFormValues) {
setIsLoading(true);
try {
@@ -201,14 +215,13 @@ export function AddTemplateDialog() { throw new Error("파일 업로드에 실패했습니다.");
}
- // 메타데이터 저장 (업데이트된 필드들 포함)
+ // 메타데이터 저장 (templateCode 제거됨)
const saveResponse = await fetch('/api/upload/basicContract/complete', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
- templateCode: formData.templateCode,
templateName: formData.templateName,
revision: formData.revision,
legalReviewRequired: formData.legalReviewRequired,
@@ -300,22 +313,28 @@ export function AddTemplateDialog() { <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<FormField
control={form.control}
- name="templateCode"
+ name="templateName"
render={({ field }) => (
<FormItem>
<FormLabel>
- 템플릿 코드 <span className="text-red-500">*</span>
+ 템플릿 이름 <span className="text-red-500">*</span>
</FormLabel>
- <FormControl>
- <Input
- placeholder="TEMPLATE_001"
- {...field}
- style={{ textTransform: 'uppercase' }}
- onChange={(e) => field.onChange(e.target.value.toUpperCase())}
- />
- </FormControl>
+ <Select onValueChange={field.onChange} defaultValue={field.value}>
+ <FormControl>
+ <SelectTrigger>
+ <SelectValue placeholder="템플릿 이름을 선택하세요" />
+ </SelectTrigger>
+ </FormControl>
+ <SelectContent>
+ {TEMPLATE_NAME_OPTIONS.map((option) => (
+ <SelectItem key={option} value={option}>
+ {option}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
<FormDescription>
- 영문 대문자, 숫자, '_', '-'만 사용 가능
+ 미리 정의된 템플릿 중에서 선택
</FormDescription>
<FormMessage />
</FormItem>
@@ -338,6 +357,10 @@ export function AddTemplateDialog() { </FormControl>
<FormDescription>
템플릿 버전 (기본값: 1)
+ <br />
+ <span className="text-xs text-muted-foreground">
+ 동일한 템플릿 이름의 리비전은 중복될 수 없습니다.
+ </span>
</FormDescription>
<FormMessage />
</FormItem>
@@ -347,22 +370,6 @@ export function AddTemplateDialog() { <FormField
control={form.control}
- name="templateName"
- render={({ field }) => (
- <FormItem>
- <FormLabel>
- 템플릿 이름 <span className="text-red-500">*</span>
- </FormLabel>
- <FormControl>
- <Input placeholder="기본 계약서 템플릿" {...field} />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
name="legalReviewRequired"
render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm">
@@ -459,18 +466,19 @@ export function AddTemplateDialog() { <Dropzone
onDrop={handleFileChange}
accept={{
- 'application/pdf': ['.pdf']
+ 'application/msword': ['.doc'],
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': ['.docx']
}}
>
<DropzoneZone>
<DropzoneUploadIcon className="h-10 w-10 text-muted-foreground" />
<DropzoneTitle>
- {selectedFile ? selectedFile.name : "PDF 파일을 여기에 드래그하세요"}
+ {selectedFile ? selectedFile.name : "워드 파일을 여기에 드래그하세요"}
</DropzoneTitle>
<DropzoneDescription>
{selectedFile
? `파일 크기: ${(selectedFile.size / (1024 * 1024)).toFixed(2)} MB`
- : "또는 클릭하여 PDF 파일을 선택하세요 (최대 100MB)"}
+ : "또는 클릭하여 워드 파일(.doc, .docx)을 선택하세요 (최대 100MB)"}
</DropzoneDescription>
<DropzoneInput />
</DropzoneZone>
|
