summaryrefslogtreecommitdiff
path: root/components/common/selectors/gl-account/gl-account-selector.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'components/common/selectors/gl-account/gl-account-selector.tsx')
-rw-r--r--components/common/selectors/gl-account/gl-account-selector.tsx30
1 files changed, 29 insertions, 1 deletions
diff --git a/components/common/selectors/gl-account/gl-account-selector.tsx b/components/common/selectors/gl-account/gl-account-selector.tsx
index 81a33944..7e47a072 100644
--- a/components/common/selectors/gl-account/gl-account-selector.tsx
+++ b/components/common/selectors/gl-account/gl-account-selector.tsx
@@ -14,7 +14,7 @@ import { useState, useCallback, useMemo, useTransition } from 'react'
import { Button } from '@/components/ui/button'
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'
import { Input } from '@/components/ui/input'
-import { Search, Check } from 'lucide-react'
+import { Search, Check, X } from 'lucide-react'
import {
ColumnDef,
flexRender,
@@ -75,8 +75,20 @@ export function GlAccountSelector({
// GL 계정 선택 핸들러
const handleCodeSelect = useCallback(async (code: GlAccount) => {
+ // 이미 선택된 계정을 다시 선택하면 선택 해제
+ if (selectedCode && selectedCode.SAKNR === code.SAKNR && selectedCode.FIPEX === code.FIPEX) {
+ onCodeSelect(undefined as any) // 선택 해제를 위해 undefined 전달
+ setOpen(false)
+ return
+ }
+
onCodeSelect(code)
setOpen(false)
+ }, [onCodeSelect, selectedCode])
+
+ // 선택 해제 핸들러
+ const handleClearSelection = useCallback(() => {
+ onCodeSelect(undefined as any) // 선택 해제를 위해 undefined 전달
}, [onCodeSelect])
// 테이블 컬럼 정의
@@ -196,6 +208,17 @@ export function GlAccountSelector({
<span className="font-mono text-sm">[{selectedCode.SAKNR}]</span>
<span className="font-mono text-sm">{selectedCode.FIPEX}</span>
<span className="truncate flex-1 text-left">{selectedCode.TEXT1}</span>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-4 w-4 p-0 hover:bg-destructive hover:text-destructive-foreground ml-1"
+ onClick={(e) => {
+ e.stopPropagation()
+ handleClearSelection()
+ }}
+ >
+ <X className="h-3 w-3" />
+ </Button>
</div>
) : (
<span className="text-muted-foreground">{placeholder}</span>
@@ -261,6 +284,11 @@ export function GlAccountSelector({
)}
</TableCell>
))}
+ {selectedCode && selectedCode.SAKNR === row.original.SAKNR && selectedCode.FIPEX === row.original.FIPEX && (
+ <TableCell className="text-right">
+ <span className="text-xs text-muted-foreground">(선택됨)</span>
+ </TableCell>
+ )}
</TableRow>
))
) : (