diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-04-28 02:13:30 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-04-28 02:13:30 +0000 |
| commit | ef4c533ebacc2cdc97e518f30e9a9350004fcdfb (patch) | |
| tree | 345251a3ed0f4429716fa5edaa31024d8f4cb560 /lib/rfqs/tbe-table/tbe-table.tsx | |
| parent | 9ceed79cf32c896f8a998399bf1b296506b2cd4a (diff) | |
~20250428 작업사항
Diffstat (limited to 'lib/rfqs/tbe-table/tbe-table.tsx')
| -rw-r--r-- | lib/rfqs/tbe-table/tbe-table.tsx | 66 |
1 files changed, 48 insertions, 18 deletions
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<DataTableRowAction<VendorWithTbeFields> | null>(null) @@ -48,13 +54,12 @@ export function TbeTable({ promises, rfqId }: VendorsTableProps) { const [initialComments, setInitialComments] = React.useState<TbeComment[]>([]) const [commentSheetOpen, setCommentSheetOpen] = React.useState(false) const [selectedRfqIdForComments, setSelectedRfqIdForComments] = React.useState<number | null>(null) - + const [isFileDialogOpen, setIsFileDialogOpen] = React.useState(false) const [selectedVendorId, setSelectedVendorId] = React.useState<number | null>(null) const [selectedTbeId, setSelectedTbeId] = React.useState<number | null>(null) - - console.log(selectedVendorId,"selectedVendorId") - console.log(rfqId,"rfqId") + const [isContactDialogOpen, setIsContactDialogOpen] = React.useState(false) + const [selectedVendor, setSelectedVendor] = React.useState<VendorWithTbeFields | null>(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 ( -<div style={{ maxWidth: '80vw' }}> + <div style={{ maxWidth: '80vw' }}> <DataTable table={table} - > + > <DataTableAdvancedToolbar table={table} filterFields={advancedFilterFields} @@ -169,11 +184,12 @@ export function TbeTable({ promises, rfqId }: VendorsTableProps) { showTrigger={false} /> <CommentSheet - currentUserId={1} + currentUserId={currentUserId} open={commentSheetOpen} onOpenChange={setCommentSheetOpen} rfqId={rfqId} - vendorId={selectedRfqIdForComments ?? 0} + tbeId={selectedTbeId ?? 0} + vendorId={selectedVendorId ?? 0} initialComments={initialComments} /> @@ -185,6 +201,20 @@ export function TbeTable({ promises, rfqId }: VendorsTableProps) { rfqId={rfqId} // Use the prop directly instead of data[0]?.rfqId onRefresh={handleRefresh} /> + + <TbeResultDialog + open={rowAction?.type === "tbeResult"} + onOpenChange={() => setRowAction(null)} + tbe={rowAction?.row.original ?? null} + /> + + <VendorContactsDialog + isOpen={isContactDialogOpen} + onOpenChange={setIsContactDialogOpen} + vendorId={selectedVendorId} + vendor={selectedVendor} + /> + </div> ) }
\ No newline at end of file |
