From cac0fb5a027338fdbd9e4f255f3e25381373414d Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Wed, 2 Apr 2025 10:56:14 +0900 Subject: bugFix: 허용되지 않는 문자가 사용된 파일명 변경 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/update-\bdoc-sheet.tsx" | 267 --------------------- .../table/update-doc-sheet.tsx | 267 +++++++++++++++++++++ 2 files changed, 267 insertions(+), 267 deletions(-) delete mode 100644 "lib/vendor-document-list/table/update-\bdoc-sheet.tsx" create mode 100644 lib/vendor-document-list/table/update-doc-sheet.tsx (limited to 'lib/vendor-document-list/table') diff --git "a/lib/vendor-document-list/table/update-\bdoc-sheet.tsx" "b/lib/vendor-document-list/table/update-\bdoc-sheet.tsx" deleted file mode 100644 index 3e0ca225..00000000 --- "a/lib/vendor-document-list/table/update-\bdoc-sheet.tsx" +++ /dev/null @@ -1,267 +0,0 @@ -"use client" - -import * as React from "react" -import { zodResolver } from "@hookform/resolvers/zod" -import { Loader, Save } from "lucide-react" -import { useForm } from "react-hook-form" -import { toast } from "sonner" -import { z } from "zod" -import { useRouter } from "next/navigation" - -import { Button } from "@/components/ui/button" -import { - Form, - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form" -import { - Select, - SelectContent, - SelectGroup, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select" -import { - Sheet, - SheetClose, - SheetContent, - SheetDescription, - SheetFooter, - SheetHeader, - SheetTitle, -} from "@/components/ui/sheet" -import { Input } from "@/components/ui/input" -import { Textarea } from "@/components/ui/textarea" -import { modifyDocument } from "../service" - -// Document 수정을 위한 Zod 스키마 정의 -const updateDocumentSchema = z.object({ - docNumber: z.string().min(1, "Document number is required"), - title: z.string().min(1, "Title is required"), - status: z.string().min(1, "Status is required"), - description: z.string().optional(), - remarks: z.string().optional() -}); - -type UpdateDocumentSchema = z.infer; - -// 상태 옵션 정의 -const statusOptions = [ - "pending", - "in-progress", - "completed", - "rejected" -]; - -interface UpdateDocumentSheetProps - extends React.ComponentPropsWithRef { - document: { - id: number; - contractId: number; - docNumber: string; - title: string; - status: string; - description?: string | null; - remarks?: string | null; - } | null -} - -export function UpdateDocumentSheet({ document, ...props }: UpdateDocumentSheetProps) { - const [isUpdatePending, startUpdateTransition] = React.useTransition() - const router = useRouter() - - const form = useForm({ - resolver: zodResolver(updateDocumentSchema), - defaultValues: { - docNumber: "", - title: "", - status: "", - description: "", - remarks: "", - }, - }) - - // 폼 초기화 (document가 변경될 때) - React.useEffect(() => { - if (document) { - form.reset({ - docNumber: document.docNumber, - title: document.title, - status: document.status, - description: document.description ?? "", - remarks: document.remarks ?? "", - }); - } - }, [document, form]); - - function onSubmit(input: UpdateDocumentSchema) { - startUpdateTransition(async () => { - if (!document) return - - const result = await modifyDocument({ - id: document.id, - contractId: document.contractId, - ...input, - }) - - if (!result.success) { - if ('error' in result) { - toast.error(result.error) - } else { - toast.error("Failed to update document") - } - return - } - - form.reset() - props.onOpenChange?.(false) - toast.success("Document updated successfully") - router.refresh() - }) - } - - return ( - - - - Update Document - - Update the document details and save the changes - - -
- - {/* 문서 번호 필드 */} - ( - - Document Number - - - - - - )} - /> - - {/* 문서 제목 필드 */} - ( - - Title - - - - - - )} - /> - - {/* 상태 필드 */} - ( - - Status - - - - )} - /> - - {/* 설명 필드 */} - ( - - Description - -