From ef4c533ebacc2cdc97e518f30e9a9350004fcdfb Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 28 Apr 2025 02:13:30 +0000 Subject: ~20250428 작업사항 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/rfqs/tbe-table/tbe-table.tsx | 66 +++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 18 deletions(-) (limited to 'lib/rfqs/tbe-table/tbe-table.tsx') diff --git a/lib/rfqs/tbe-table/tbe-table.tsx b/lib/rfqs/tbe-table/tbe-table.tsx index 41eff0dc..0add8927 100644 --- a/lib/rfqs/tbe-table/tbe-table.tsx +++ b/lib/rfqs/tbe-table/tbe-table.tsx @@ -21,6 +21,9 @@ import { InviteVendorsDialog } from "./invite-vendors-dialog" import { CommentSheet, TbeComment } from "./comments-sheet" import { VendorWithTbeFields } from "@/config/vendorTbeColumnsConfig" import { TBEFileDialog } from "./file-dialog" +import { TbeResultDialog } from "./tbe-result-dialog" +import { VendorContactsDialog } from "./vendor-contact-dialog" +import { useSession } from "next-auth/react" // Next-auth session hook 추가 interface VendorsTableProps { promises: Promise< @@ -37,8 +40,11 @@ export function TbeTable({ promises, rfqId }: VendorsTableProps) { // Suspense로 받아온 데이터 const [{ data, pageCount }] = React.use(promises) + console.log("data", data) + const { data: session } = useSession() // 세션 정보 가져오기 + + const currentUserId = session?.user?.id ? parseInt(session.user.id, 10) : 0 - console.log(data) const [rowAction, setRowAction] = React.useState | null>(null) @@ -48,13 +54,12 @@ export function TbeTable({ promises, rfqId }: VendorsTableProps) { const [initialComments, setInitialComments] = React.useState([]) const [commentSheetOpen, setCommentSheetOpen] = React.useState(false) const [selectedRfqIdForComments, setSelectedRfqIdForComments] = React.useState(null) - + const [isFileDialogOpen, setIsFileDialogOpen] = React.useState(false) const [selectedVendorId, setSelectedVendorId] = React.useState(null) const [selectedTbeId, setSelectedTbeId] = React.useState(null) - - console.log(selectedVendorId,"selectedVendorId") - console.log(rfqId,"rfqId") + const [isContactDialogOpen, setIsContactDialogOpen] = React.useState(false) + const [selectedVendor, setSelectedVendor] = React.useState(null) // Add handleRefresh function const handleRefresh = React.useCallback(() => { @@ -73,11 +78,14 @@ export function TbeTable({ promises, rfqId }: VendorsTableProps) { } }, [rowAction]) - async function openCommentSheet(vendorId: number) { + async function openCommentSheet(a: number) { setInitialComments([]) - + const comments = rowAction?.row.original.comments - + const rfqId = rowAction?.row.original.rfqId + const vendorId = rowAction?.row.original.vendorId + const tbeId = rowAction?.row.original.tbeId + console.log("original", rowAction?.row.original) if (comments && comments.length > 0) { const commentWithAttachments: TbeComment[] = await Promise.all( comments.map(async (c) => { @@ -85,7 +93,7 @@ export function TbeTable({ promises, rfqId }: VendorsTableProps) { return { ...c, - commentedBy: 1, // DB나 API 응답에 있다고 가정 + commentedBy: currentUserId, // DB나 API 응답에 있다고 가정 attachments, } }) @@ -93,8 +101,9 @@ export function TbeTable({ promises, rfqId }: VendorsTableProps) { // 3) state에 저장 -> CommentSheet에서 initialComments로 사용 setInitialComments(commentWithAttachments) } - - setSelectedRfqIdForComments(vendorId) + setSelectedTbeId(tbeId ?? 0) + setSelectedVendorId(vendorId ?? 0) + setSelectedRfqIdForComments(rfqId ?? 0) setCommentSheetOpen(true) } @@ -103,11 +112,15 @@ export function TbeTable({ promises, rfqId }: VendorsTableProps) { setSelectedVendorId(vendorId) setIsFileDialogOpen(true) } - + const openVendorContactsDialog = (vendorId: number, vendor: VendorWithTbeFields) => { + setSelectedVendorId(vendorId) + setSelectedVendor(vendor) + setIsContactDialogOpen(true) + } // getColumns() 호출 시, router를 주입 const columns = React.useMemo( - () => getColumns({ setRowAction, router, openCommentSheet, openFilesDialog }), + () => getColumns({ setRowAction, router, openCommentSheet, openFilesDialog, openVendorContactsDialog }), [setRowAction, router] ) @@ -141,18 +154,20 @@ export function TbeTable({ promises, rfqId }: VendorsTableProps) { enableAdvancedFilter: true, initialState: { sorting: [{ id: "rfqVendorUpdated", desc: true }], - columnPinning: { right: ["actions"] }, + columnPinning: { right: ["comments"] }, }, getRowId: (originalRow) => String(originalRow.id), shallow: false, clearOnDefault: true, }) + + return ( -
+
+ > @@ -185,6 +201,20 @@ export function TbeTable({ promises, rfqId }: VendorsTableProps) { rfqId={rfqId} // Use the prop directly instead of data[0]?.rfqId onRefresh={handleRefresh} /> + + setRowAction(null)} + tbe={rowAction?.row.original ?? null} + /> + + +
) } \ No newline at end of file -- cgit v1.2.3