diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-11-03 10:15:45 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-11-03 10:15:45 +0000 |
| commit | f2fafe555b65f9207c2c6e216b7d7b2ff83af866 (patch) | |
| tree | 4a230e4bde10a612150a299922bc04cb15b0930f /lib/vendor-investigation/table/investigation-table-toolbar-actions.tsx | |
| parent | 1e857a0b1443ad2124caf3d180b7195651fe33e4 (diff) | |
(최겸) 구매 PQ/실사 수정
Diffstat (limited to 'lib/vendor-investigation/table/investigation-table-toolbar-actions.tsx')
| -rw-r--r-- | lib/vendor-investigation/table/investigation-table-toolbar-actions.tsx | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/lib/vendor-investigation/table/investigation-table-toolbar-actions.tsx b/lib/vendor-investigation/table/investigation-table-toolbar-actions.tsx index 991c1ad6..371873e4 100644 --- a/lib/vendor-investigation/table/investigation-table-toolbar-actions.tsx +++ b/lib/vendor-investigation/table/investigation-table-toolbar-actions.tsx @@ -2,13 +2,14 @@ import * as React from "react" import { type Table } from "@tanstack/react-table" -import { Download, RotateCcw } from "lucide-react" +import { Download, RotateCcw, UserCog } from "lucide-react" import { toast } from "sonner" import { exportTableToExcel } from "@/lib/export" import { Button } from "@/components/ui/button" import { VendorInvestigationsViewWithContacts } from "@/config/vendorInvestigationsColumnsConfig" import { InvestigationCancelPlanButton } from "./investigation-cancel-plan-button" +import { ChangeQMManagerDialog } from "./change-qm-manager-dialog" interface VendorsTableToolbarActionsProps { @@ -16,13 +17,46 @@ interface VendorsTableToolbarActionsProps { } export function VendorsTableToolbarActions({ table }: VendorsTableToolbarActionsProps) { - // 파일 input을 숨기고, 버튼 클릭 시 참조해 클릭하는 방식 + // 선택된 행 분석 + const selectedRows = table.getFilteredSelectedRowModel().rows + const selectedData = selectedRows.map(row => row.original) + // QM 담당자 변경 가능 여부 체크 (선택된 항목이 1개이고 상태가 PLANNED) + const canChangeQM = selectedData.length === 1 && selectedData[0].investigationStatus === "PLANNED" + const selectedInvestigation = canChangeQM ? selectedData[0] : null + + // QM 담당자 변경 다이얼로그 상태 + const [showChangeQMDialog, setShowChangeQMDialog] = React.useState(false) + + const handleChangeQMClick = () => { + if (canChangeQM) { + setShowChangeQMDialog(true) + } + } + + const handleChangeQMSuccess = () => { + // 테이블 선택 초기화 + table.toggleAllPageRowsSelected(false) + setShowChangeQMDialog(false) + } return ( <div className="flex items-center gap-2"> <InvestigationCancelPlanButton table={table} /> + {/* QM 담당자 변경 버튼 - 계획 상태이고 단일 선택일 때만 활성화 */} + {canChangeQM && ( + <Button + variant="outline" + size="sm" + onClick={handleChangeQMClick} + className="gap-2" + > + <UserCog className="size-4" aria-hidden="true" /> + <span className="hidden sm:inline">QM 담당자 변경</span> + </Button> + )} + {/** 4) Export 버튼 */} <Button variant="outline" @@ -38,6 +72,18 @@ export function VendorsTableToolbarActions({ table }: VendorsTableToolbarActions <Download className="size-4" aria-hidden="true" /> <span className="hidden sm:inline">Export</span> </Button> + + {/* QM 담당자 변경 다이얼로그 */} + {selectedInvestigation && ( + <ChangeQMManagerDialog + isOpen={showChangeQMDialog} + onClose={() => setShowChangeQMDialog(false)} + investigationId={selectedInvestigation.investigationId} + currentQMManagerId={selectedInvestigation.qmManagerId} + currentQMManagerName={selectedInvestigation.qmManagerName} + onSuccess={handleChangeQMSuccess} + /> + )} </div> ) }
\ No newline at end of file |
