diff options
Diffstat (limited to 'lib/vendor-regular-registrations/table')
| -rw-r--r-- | lib/vendor-regular-registrations/table/safety-qualification-update-dialog.tsx | 143 | ||||
| -rw-r--r-- | lib/vendor-regular-registrations/table/vendor-regular-registrations-table-columns.tsx | 25 |
2 files changed, 1 insertions, 167 deletions
diff --git a/lib/vendor-regular-registrations/table/safety-qualification-update-dialog.tsx b/lib/vendor-regular-registrations/table/safety-qualification-update-dialog.tsx deleted file mode 100644 index 80084732..00000000 --- a/lib/vendor-regular-registrations/table/safety-qualification-update-dialog.tsx +++ /dev/null @@ -1,143 +0,0 @@ -"use client" - -import * as React from "react" -import { useForm } from "react-hook-form" -import { zodResolver } from "@hookform/resolvers/zod" -import { z } from "zod" -import { toast } from "sonner" - -import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, -} from "@/components/ui/dialog" -import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form" -import { Button } from "@/components/ui/button" -import { Textarea } from "@/components/ui/textarea" -import { updateSafetyQualification } from "../service" - -const formSchema = z.object({ - safetyQualificationContent: z.string().min(1, "안전적격성 평가 내용을 입력해주세요."), -}) - -interface SafetyQualificationUpdateDialogProps { - open: boolean - onOpenChange: (open: boolean) => void - registrationId?: number - vendorName?: string - currentContent?: string | null - onSuccess?: () => void -} - -export function SafetyQualificationUpdateDialog({ - open, - onOpenChange, - registrationId, - vendorName, - currentContent, - onSuccess, -}: SafetyQualificationUpdateDialogProps) { - const [isLoading, setIsLoading] = React.useState(false) - - const form = useForm<z.infer<typeof formSchema>>({ - resolver: zodResolver(formSchema), - defaultValues: { - safetyQualificationContent: currentContent || "", - }, - }) - - // 폼 값 초기화 - React.useEffect(() => { - if (open) { - form.reset({ - safetyQualificationContent: currentContent || "", - }) - } - }, [open, currentContent, form]) - - async function onSubmit(values: z.infer<typeof formSchema>) { - if (!registrationId) { - toast.error("등록 ID가 없습니다.") - return - } - - setIsLoading(true) - try { - const result = await updateSafetyQualification( - registrationId, - values.safetyQualificationContent - ) - - if (result.success) { - toast.success("안전적격성 평가가 등록되었습니다.") - onOpenChange(false) - onSuccess?.() - } else { - toast.error(result.error || "안전적격성 평가 등록에 실패했습니다.") - } - } catch (error) { - console.error("안전적격성 평가 등록 오류:", error) - toast.error("안전적격성 평가 등록 중 오류가 발생했습니다.") - } finally { - setIsLoading(false) - } - } - - return ( - <Dialog open={open} onOpenChange={onOpenChange}> - <DialogContent className="w-[400px] sm:w-[540px] max-h-[90vh] overflow-y-auto"> - <DialogHeader> - <DialogTitle>안전적격성 평가 입력</DialogTitle> - <DialogDescription> - {vendorName && `${vendorName}의 `}안전적격성 평가 내용을 입력해주세요. - </DialogDescription> - </DialogHeader> - - <Form {...form}> - <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6 mt-6"> - <FormField - control={form.control} - name="safetyQualificationContent" - render={({ field }) => ( - <FormItem> - <FormLabel>안전적격성 평가 내용</FormLabel> - <FormControl> - <Textarea - placeholder="안전적격성 평가 결과 및 내용을 입력해주세요..." - className="min-h-[200px]" - {...field} - /> - </FormControl> - <FormMessage /> - </FormItem> - )} - /> - - <div className="flex justify-end space-x-2"> - <Button - type="button" - variant="outline" - onClick={() => onOpenChange(false)} - disabled={isLoading} - > - 취소 - </Button> - <Button type="submit" disabled={isLoading}> - {isLoading ? "저장 중..." : "저장"} - </Button> - </div> - </form> - </Form> - </DialogContent> - </Dialog> - ) -} diff --git a/lib/vendor-regular-registrations/table/vendor-regular-registrations-table-columns.tsx b/lib/vendor-regular-registrations/table/vendor-regular-registrations-table-columns.tsx index 075724a2..2e3920af 100644 --- a/lib/vendor-regular-registrations/table/vendor-regular-registrations-table-columns.tsx +++ b/lib/vendor-regular-registrations/table/vendor-regular-registrations-table-columns.tsx @@ -10,9 +10,8 @@ import { VendorRegularRegistration, statusLabels, statusColors } from "@/config/ import { DocumentStatusDialog } from "@/components/vendor-regular-registrations/document-status-dialog" import { Button } from "@/components/ui/button" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu" -import { Ellipsis, Shield, Package } from "lucide-react" +import { Ellipsis, Package } from "lucide-react" import { useState } from "react" -import { SafetyQualificationUpdateDialog } from "./safety-qualification-update-dialog" import { MajorItemsUpdateDialog } from "./major-items-update-dialog" export function getColumns(): ColumnDef<VendorRegularRegistration>[] { @@ -177,9 +176,6 @@ export function getColumns(): ColumnDef<VendorRegularRegistration>[] { const completedContracts = registration.basicContracts?.filter(c => c.status === "VENDOR_SIGNED" || c.status === "COMPLETED").length || 0 const incompleteContracts = totalContracts - completedContracts - // 안전적격성 평가 현황 - const safetyCompleted = !!registration.safetyQualificationContent - // 추가정보 현황 const additionalInfoCompleted = registration.additionalInfo @@ -187,7 +183,6 @@ export function getColumns(): ColumnDef<VendorRegularRegistration>[] { const totalIncomplete = (incompleteDocs > 0 ? 1 : 0) + incompleteContracts + - (!safetyCompleted ? 1 : 0) + (!additionalInfoCompleted ? 1 : 0) const isAllComplete = totalIncomplete === 0 @@ -260,7 +255,6 @@ export function getColumns(): ColumnDef<VendorRegularRegistration>[] { id: "actions", cell: ({ row }) => { const ActionsDropdownCell = () => { - const [safetyQualificationSheetOpen, setSafetyQualificationSheetOpen] = useState(false) const [majorItemsSheetOpen, setMajorItemsSheetOpen] = useState(false) const registration = row.original @@ -278,12 +272,6 @@ export function getColumns(): ColumnDef<VendorRegularRegistration>[] { </DropdownMenuTrigger> <DropdownMenuContent align="end" className="w-[160px]"> <DropdownMenuItem - onClick={() => setSafetyQualificationSheetOpen(true)} - > - <Shield className="mr-2 h-4 w-4" /> - 안전적격성 평가 - </DropdownMenuItem> - <DropdownMenuItem onClick={() => setMajorItemsSheetOpen(true)} > <Package className="mr-2 h-4 w-4" /> @@ -292,17 +280,6 @@ export function getColumns(): ColumnDef<VendorRegularRegistration>[] { </DropdownMenuContent> </DropdownMenu> - <SafetyQualificationUpdateDialog - open={safetyQualificationSheetOpen} - onOpenChange={setSafetyQualificationSheetOpen} - registrationId={registration.id} - vendorName={registration.companyName} - currentContent={registration.safetyQualificationContent} - onSuccess={() => { - // 페이지 새로고침 또는 데이터 리페치 - window.location.reload() - }} - /> <MajorItemsUpdateDialog open={majorItemsSheetOpen} onOpenChange={setMajorItemsSheetOpen} |
