From ee57cc221ff2edafd3c0f12a181214c602ed257e Mon Sep 17 00:00:00 2001 From: dujinkim Date: Tue, 22 Jul 2025 02:57:00 +0000 Subject: (대표님, 최겸) 이메일 템플릿, 벤더데이터 변경사항 대응, 기술영업 변경요구사항 구현 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/email-template/table/update-template-sheet.tsx | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'lib/email-template/table/update-template-sheet.tsx') diff --git a/lib/email-template/table/update-template-sheet.tsx b/lib/email-template/table/update-template-sheet.tsx index 58da0626..d3df93f0 100644 --- a/lib/email-template/table/update-template-sheet.tsx +++ b/lib/email-template/table/update-template-sheet.tsx @@ -7,6 +7,7 @@ import { Loader } from "lucide-react" import { useForm } from "react-hook-form" import { toast } from "sonner" import { z } from "zod" +import { useSession } from "next-auth/react" import { Button } from "@/components/ui/button" import { @@ -55,6 +56,13 @@ interface UpdateTemplateSheetProps export function UpdateTemplateSheet({ template, ...props }: UpdateTemplateSheetProps) { const [isUpdatePending, startUpdateTransition] = React.useTransition() + const { data: session } = useSession(); + + // 또는 더 안전하게 + if (!session?.user?.id) { + toast.error("로그인이 필요합니다") + return + } const form = useForm({ resolver: zodResolver(updateTemplateSchema), @@ -85,8 +93,10 @@ export function UpdateTemplateSheet({ template, ...props }: UpdateTemplateSheetP const { error } = await updateTemplateAction(template.slug, { name: input.name, description: input.description || undefined, + category: input.category === "none" ? undefined : input.category, // 여기서 변환 + // category는 일반적으로 수정하지 않는 것이 좋지만, 필요시 포함 - updatedBy: currentUserId, + updatedBy: Number(session.user.id), }) if (error) { @@ -165,13 +175,13 @@ export function UpdateTemplateSheet({ template, ...props }: UpdateTemplateSheetP - 카테고리 없음 - {TEMPLATE_CATEGORY_OPTIONS.map((option) => ( - - {option.label} - - ))} - + 카테고리 없음 + {TEMPLATE_CATEGORY_OPTIONS.map((option) => ( + + {option.label} + + ))} + -- cgit v1.2.3