From 2650b7c0bb0ea12b68a58c0439f72d61df04b2f1 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Fri, 25 Jul 2025 07:51:15 +0000
Subject: (대표님) 정기평가 대상, 미들웨어 수정, nextauth 토큰 처리 개선, GTC
 등 (최겸) 기술영업
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/gtc-contract/status/create-gtc-document-dialog.tsx | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

(limited to 'lib/gtc-contract/status/create-gtc-document-dialog.tsx')

diff --git a/lib/gtc-contract/status/create-gtc-document-dialog.tsx b/lib/gtc-contract/status/create-gtc-document-dialog.tsx
index 6791adfa..98cd249f 100644
--- a/lib/gtc-contract/status/create-gtc-document-dialog.tsx
+++ b/lib/gtc-contract/status/create-gtc-document-dialog.tsx
@@ -42,11 +42,18 @@ import { toast } from "sonner"
 import { createGtcDocumentSchema, type CreateGtcDocumentSchema } from "@/lib/gtc-contract/validations"
 import { createGtcDocument, getProjectsForSelect } from "@/lib/gtc-contract/service"
 import { type Project } from "@/db/schema/projects"
+import { useSession } from "next-auth/react"
 
 export function CreateGtcDocumentDialog() {
   const [open, setOpen] = React.useState(false)
   const [projects, setProjects] = React.useState<Project[]>([])
   const [isCreatePending, startCreateTransition] = React.useTransition()
+  const { data: session } = useSession()
+
+  const currentUserId =React.useMemo(() => {
+    return session?.user?.id ? Number(session.user.id) : null;
+  }, [session]);
+
 
   React.useEffect(() => {
     if (open) {
@@ -70,8 +77,17 @@ export function CreateGtcDocumentDialog() {
 
   async function onSubmit(data: CreateGtcDocumentSchema) {
     startCreateTransition(async () => {
+
+      if (!currentUserId) {
+        toast.error("로그인이 필요합니다")
+        return
+      }
+
       try {
-        const result = await createGtcDocument(data)
+        const result = await createGtcDocument({
+          ...data,
+          createdById: currentUserId
+        })
         
         if (result.error) {
           toast.error(`에러: ${result.error}`)
-- 
cgit v1.2.3

