From 44794a8628997c0d979adb5bd6711cd848b3e397 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Wed, 9 Jul 2025 06:27:10 +0000 Subject: (최겸) 기술영업 판교 미팅 이전 rfq-tech 삭제 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vendor-table/vendor-list/vendor-list-table.tsx | 176 --------------------- 1 file changed, 176 deletions(-) delete mode 100644 lib/rfqs-tech/vendor-table/vendor-list/vendor-list-table.tsx (limited to 'lib/rfqs-tech/vendor-table/vendor-list/vendor-list-table.tsx') diff --git a/lib/rfqs-tech/vendor-table/vendor-list/vendor-list-table.tsx b/lib/rfqs-tech/vendor-table/vendor-list/vendor-list-table.tsx deleted file mode 100644 index defbac86..00000000 --- a/lib/rfqs-tech/vendor-table/vendor-list/vendor-list-table.tsx +++ /dev/null @@ -1,176 +0,0 @@ -"use client" - -import * as React from "react" -import { ClientDataTable } from "@/components/client-data-table/data-table" -import { getColumns } from "./vendor-list-table-column" -import { DataTableAdvancedFilterField } from "@/types/table" -import { addItemToVendors, getAllVendors } from "../../service" -import { Loader2, Plus } from "lucide-react" -import { Button } from "@/components/ui/button" -import { useToast } from "@/hooks/use-toast" - -export interface VendorData { - id: number - vendorName: string - vendorCode: string | null - taxId: string - address: string | null - country: string | null - phone: string | null - email: string | null - website: string | null - status: string - createdAt: Date - updatedAt: Date -} - -interface VendorsListTableProps { - rfqId: number -} - -export function VendorsListTable({ rfqId }: VendorsListTableProps) { - const { toast } = useToast() - - // Changed to array for multiple selection - const [selectedVendorIds, setSelectedVendorIds] = React.useState([]) - const [isSubmitting, setIsSubmitting] = React.useState(false) - - const [vendors, setVendors] = React.useState([]) - const [isLoading, setIsLoading] = React.useState(false) - - const columns = React.useMemo( - () => getColumns({ setSelectedVendorIds }), - [setSelectedVendorIds] - ) - - // 고급 필터 필드 정의 - const advancedFilterFields: DataTableAdvancedFilterField[] = [ - { - id: "vendorName", - label: "Vendor Name", - type: "text", - }, - { - id: "vendorCode", - label: "Vendor Code", - type: "text", - }, - { - id: "status", - label: "Status", - type: "select", - options: [ - { label: "Active", value: "ACTIVE" }, - { label: "Inactive", value: "INACTIVE" }, - { label: "Pending", value: "PENDING" }, - ], - }, - { - id: "country", - label: "Country", - type: "text", - }, - { - id: "email", - label: "Email", - type: "text", - }, - ] - - // 초기 데이터 로드 - React.useEffect(() => { - async function loadVendors() { - setIsLoading(true) - try { - const result = await getAllVendors() - - if (result.data) { - setVendors(result.data) - } - } catch (error) { - console.error("협력업체 목록 로드 오류:", error) - toast({ - title: "Error", - description: "Failed to load vendors", - variant: "destructive", - }) - } finally { - setIsLoading(false) - } - } - - loadVendors() - }, [toast]) - - async function handleAddVendors() { - if (selectedVendorIds.length === 0) return // Safety check - - setIsSubmitting(true) - try { - // Update to use the multiple vendor service - const result = await addItemToVendors(rfqId, selectedVendorIds) - - if (result.success) { - toast({ - title: "Success", - description: `Added items to ${selectedVendorIds.length} vendors`, - }) - // Reset selection after successful addition - setSelectedVendorIds([]) - } else { - toast({ - title: "Error", - description: result.error || "Failed to add items to vendors", - variant: "destructive", - }) - } - } catch (err) { - console.error("Failed to add vendors:", err) - toast({ - title: "Error", - description: "An unexpected error occurred", - variant: "destructive", - }) - } finally { - setIsSubmitting(false) - } - } - - // If loading, show a flex container that fills the parent and centers the spinner - if (isLoading && vendors.length === 0) { - return ( -
- -
- ) - } - - return ( - -
- -
-
- ) -} \ No newline at end of file -- cgit v1.2.3