summaryrefslogtreecommitdiff
path: root/lib/po/vendor-table/vendor-po-table.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/po/vendor-table/vendor-po-table.tsx')
-rw-r--r--lib/po/vendor-table/vendor-po-table.tsx53
1 files changed, 31 insertions, 22 deletions
diff --git a/lib/po/vendor-table/vendor-po-table.tsx b/lib/po/vendor-table/vendor-po-table.tsx
index 99b0e5eb..7e7cb78f 100644
--- a/lib/po/vendor-table/vendor-po-table.tsx
+++ b/lib/po/vendor-table/vendor-po-table.tsx
@@ -17,6 +17,7 @@ import { getVendorColumns } from "./vendor-po-columns"
import { VendorPO, VendorPOActionType } from "./types"
import { VendorPOItemsDialog } from "./vendor-po-items-dialog"
import { VendorPONoteDialog } from "./vendor-po-note-dialog"
+import { VendorPOPrintDialog } from "./vendor-po-print-dialog"
import { VendorPOToolbarActions } from "./vendor-po-toolbar-actions"
interface VendorPoTableProps {
@@ -30,7 +31,7 @@ interface VendorPoTableProps {
export function VendorPoTable({ promises }: VendorPoTableProps) {
const router = useRouter()
const params = useParams()
- const lng = params.lng as string
+ const lng = (params?.lng as string) || 'ko'
const [data, setData] = React.useState<{
data: VendorPO[];
@@ -53,16 +54,33 @@ export function VendorPoTable({ promises }: VendorPoTableProps) {
// 다이얼로그 상태
const [itemsDialogOpen, setItemsDialogOpen] = React.useState(false)
const [noteDialogOpen, setNoteDialogOpen] = React.useState(false)
+ const [printDialogOpen, setPrintDialogOpen] = React.useState(false)
const [selectedPO, setSelectedPO] = React.useState<VendorPO | null>(null)
// 행 선택 처리 (1개만 선택 가능)
- const handleRowSelect = (id: number, selected: boolean) => {
+ const handleRowSelect = React.useCallback((id: number, selected: boolean) => {
if (selected) {
setSelectedRows([id]) // 1개만 선택
} else {
setSelectedRows([])
}
- }
+ }, [])
+
+ // 액션 처리 함수
+ const handleAction = React.useCallback(async (poId: number, action: string) => {
+ try {
+ const result = await handleVendorPOAction(poId, action)
+ if (result.success) {
+ toast.success(result.message)
+ // 필요시 데이터 새로고침
+ } else {
+ toast.error(result.message)
+ }
+ } catch (error) {
+ console.error("Action error:", error)
+ toast.error("액션 처리 중 오류가 발생했습니다.")
+ }
+ }, [])
// 행 액션 처리
React.useEffect(() => {
@@ -88,7 +106,7 @@ export function VendorPoTable({ promises }: VendorPoTableProps) {
handleAction(po.id, "reject-contract")
break
case "print-contract":
- handleAction(po.id, "print-contract")
+ setPrintDialogOpen(true)
break
case "item-status":
setItemsDialogOpen(true)
@@ -107,23 +125,7 @@ export function VendorPoTable({ promises }: VendorPoTableProps) {
}
setRowAction(null)
- }, [rowAction])
-
- // 액션 처리 함수
- const handleAction = async (poId: number, action: string) => {
- try {
- const result = await handleVendorPOAction(poId, action)
- if (result.success) {
- toast.success(result.message)
- // 필요시 데이터 새로고침
- } else {
- toast.error(result.message)
- }
- } catch (error) {
- console.error("Action error:", error)
- toast.error("액션 처리 중 오류가 발생했습니다.")
- }
- }
+ }, [rowAction, lng, router, handleAction])
const columns = React.useMemo(
() => getVendorColumns({
@@ -131,7 +133,7 @@ export function VendorPoTable({ promises }: VendorPoTableProps) {
selectedRows,
onRowSelect: handleRowSelect
}),
- [selectedRows]
+ [selectedRows, handleRowSelect]
)
const filterFields: DataTableFilterField<VendorPO>[] = [
@@ -247,6 +249,7 @@ export function VendorPoTable({ promises }: VendorPoTableProps) {
open={itemsDialogOpen}
onOpenChange={setItemsDialogOpen}
po={selectedPO}
+ viewerType="partners"
/>
<VendorPONoteDialog
@@ -254,6 +257,12 @@ export function VendorPoTable({ promises }: VendorPoTableProps) {
onOpenChange={setNoteDialogOpen}
po={selectedPO}
/>
+
+ <VendorPOPrintDialog
+ open={printDialogOpen}
+ onOpenChange={setPrintDialogOpen}
+ po={selectedPO}
+ />
</>
)
} \ No newline at end of file