From b75b1cd920efd61923f7b2dbc4c49987b7b0c4e1 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Thu, 20 Nov 2025 10:25:41 +0000
Subject: (최겸) 구매 입찰 수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../selectors/gl-account/gl-account-selector.tsx   | 30 +++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

(limited to 'components/common/selectors/gl-account/gl-account-selector.tsx')

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>
                     ))
                   ) : (
-- 
cgit v1.2.3

