From ef4c533ebacc2cdc97e518f30e9a9350004fcdfb Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 28 Apr 2025 02:13:30 +0000
Subject: ~20250428 작업사항
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/vendor-candidates/table/delete-candidates-dialog.tsx | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

(limited to 'lib/vendor-candidates/table/delete-candidates-dialog.tsx')

diff --git a/lib/vendor-candidates/table/delete-candidates-dialog.tsx b/lib/vendor-candidates/table/delete-candidates-dialog.tsx
index e9fabf76..bc231109 100644
--- a/lib/vendor-candidates/table/delete-candidates-dialog.tsx
+++ b/lib/vendor-candidates/table/delete-candidates-dialog.tsx
@@ -28,12 +28,13 @@ import {
   DrawerTrigger,
 } from "@/components/ui/drawer"
 
-import { VendorCandidates } from "@/db/schema/vendors"
 import { removeCandidates } from "../service"
+import { VendorCandidatesWithVendorInfo } from "@/db/schema"
+import { useSession } from "next-auth/react" // next-auth 세션 훅
 
 interface DeleteCandidatesDialogProps
   extends React.ComponentPropsWithoutRef<typeof Dialog> {
-  candidates: Row<VendorCandidates>["original"][]
+  candidates: Row<VendorCandidatesWithVendorInfo>["original"][]
   showTrigger?: boolean
   onSuccess?: () => void
 }
@@ -46,12 +47,21 @@ export function DeleteCandidatesDialog({
 }: DeleteCandidatesDialogProps) {
   const [isDeletePending, startDeleteTransition] = React.useTransition()
   const isDesktop = useMediaQuery("(min-width: 640px)")
+  const { data: session, status } = useSession()
 
   function onDelete() {
     startDeleteTransition(async () => {
+
+      if (!session?.user?.id) {
+        toast.error("인증 오류. 로그인 정보를 찾을 수 없습니다.")
+        return
+      }
+
+      const userId = Number(session.user.id)
+
       const { error } = await removeCandidates({
         ids: candidates.map((candidate) => candidate.id),
-      })
+      }, userId)
 
       if (error) {
         toast.error(error)
-- 
cgit v1.2.3

