From 49d6e7e271f7e11230d28e895e58ebd9c9915e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Mon, 26 Jan 2026 11:22:39 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20V2=20=EA=B2=AC=EC=A0=81=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=EC=9E=90=20=ED=95=98=EB=93=9C=EC=BD=94=EB=94=A9=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=20-=20currentUser=20=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - INITIAL_FORM_DATA.writer "드미트리" → "" 변경 - useAuth() 훅으로 currentUser.name 사용 - create 모드에서만 자동 설정 (edit/view는 기존 값 유지) - useEffect로 지연 로딩 처리 --- src/components/quotes/QuoteRegistrationV2.tsx | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/components/quotes/QuoteRegistrationV2.tsx b/src/components/quotes/QuoteRegistrationV2.tsx index 871ab062..719e8e1a 100644 --- a/src/components/quotes/QuoteRegistrationV2.tsx +++ b/src/components/quotes/QuoteRegistrationV2.tsx @@ -43,6 +43,7 @@ import { } from "./actions"; import { getClients } from "../accounting/VendorManagement/actions"; import { isNextRedirectError } from "@/lib/utils/redirect-error"; +import { useAuth } from "@/contexts/AuthContext"; import type { Vendor } from "../accounting/VendorManagement"; import type { BomMaterial, CalculationResults } from "./types"; @@ -115,7 +116,7 @@ const createNewLocation = (): LocationItem => ({ // 초기 폼 데이터 const INITIAL_FORM_DATA: QuoteFormDataV2 = { registrationDate: new Date().toISOString().split("T")[0], - writer: "드미트리", // TODO: 로그인 사용자 정보 + writer: "", // useAuth()에서 currentUser.name으로 설정됨 clientId: "", clientName: "", siteName: "", @@ -155,12 +156,22 @@ export function QuoteRegistrationV2({ isLoading = false, hideHeader = false, }: QuoteRegistrationV2Props) { + // --------------------------------------------------------------------------- + // 인증 정보 + // --------------------------------------------------------------------------- + const { currentUser } = useAuth(); + // --------------------------------------------------------------------------- // 상태 // --------------------------------------------------------------------------- - const [formData, setFormData] = useState( - initialData || INITIAL_FORM_DATA - ); + const [formData, setFormData] = useState(() => { + const data = initialData || INITIAL_FORM_DATA; + // create 모드에서 writer가 비어있으면 현재 사용자명으로 설정 + if (mode === "create" && !data.writer && currentUser?.name) { + return { ...data, writer: currentUser.name }; + } + return data; + }); const [selectedLocationId, setSelectedLocationId] = useState(null); const [isSaving, setIsSaving] = useState(false); const [isCalculating, setIsCalculating] = useState(false); @@ -199,6 +210,15 @@ export function QuoteRegistrationV2({ })); }, [formData.locations]); + // --------------------------------------------------------------------------- + // 작성자 자동 설정 (create 모드에서 currentUser 로드 시) + // --------------------------------------------------------------------------- + useEffect(() => { + if (mode === "create" && !formData.writer && currentUser?.name) { + setFormData((prev) => ({ ...prev, writer: currentUser.name })); + } + }, [mode, currentUser?.name, formData.writer]); + // --------------------------------------------------------------------------- // 초기 데이터 로드 // ---------------------------------------------------------------------------