From dfdfae3018f8499240f48d28ce634f4a5c56e006 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Wed, 2 Apr 2025 09:54:08 +0000 Subject: 벤더 코멘트 처리 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/vendor-data/vendor-data-container.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'components/vendor-data/vendor-data-container.tsx') diff --git a/components/vendor-data/vendor-data-container.tsx b/components/vendor-data/vendor-data-container.tsx index 69c22b79..11aa6f9d 100644 --- a/components/vendor-data/vendor-data-container.tsx +++ b/components/vendor-data/vendor-data-container.tsx @@ -6,7 +6,7 @@ import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@/componen import { cn } from "@/lib/utils" import { ProjectSwitcher } from "./project-swicher" import { Sidebar } from "./sidebar" -import { useParams, usePathname, useRouter } from "next/navigation" +import { usePathname, useRouter } from "next/navigation" import { getFormsByContractItemId, type FormInfo } from "@/lib/forms/services" import { Separator } from "@/components/ui/separator" @@ -36,7 +36,9 @@ interface VendorDataContainerProps { children: React.ReactNode } -function getTagIdFromPathname(path: string): number | null { +function getTagIdFromPathname(path: string | null): number | null { + if (!path) return null; + // 태그 패턴 검사 (/tag/123) const tagMatch = path.match(/\/tag\/(\d+)/) if (tagMatch) return parseInt(tagMatch[1], 10) @@ -47,6 +49,7 @@ function getTagIdFromPathname(path: string): number | null { return null } + export function VendorDataContainer({ projects, defaultLayout = [20, 80], @@ -55,9 +58,10 @@ export function VendorDataContainer({ children }: VendorDataContainerProps) { const pathname = usePathname() - const router = useRouter() + const tagIdNumber = getTagIdFromPathname(pathname) + const [isCollapsed, setIsCollapsed] = React.useState(defaultCollapsed) // 폼 로드 요청 추적 const lastRequestIdRef = React.useRef(0) @@ -70,16 +74,18 @@ export function VendorDataContainer({ // URL에서 들어온 tagIdNumber를 우선으로 설정하기 위해 초기에 null로 두고, 뒤에서 useEffect로 세팅 const [selectedPackageId, setSelectedPackageId] = React.useState(null) + const [formList, setFormList] = React.useState([]) const [selectedFormCode, setSelectedFormCode] = React.useState(null) const [isLoadingForms, setIsLoadingForms] = React.useState(false) + // 현재 선택된 프로젝트/계약/패키지 const currentProject = projects.find((p) => p.projectId === selectedProjectId) ?? projects[0] const currentContract = currentProject?.contracts.find((c) => c.contractId === selectedContractId) ?? currentProject?.contracts[0] - const isTagOrFormRoute = pathname.includes("/tag/") || pathname.includes("/form/") + const isTagOrFormRoute = pathname ? (pathname.includes("/tag/") || pathname.includes("/form/")) : false const currentPackageName = isTagOrFormRoute ? currentContract?.packages.find((pkg) => pkg.itemId === selectedPackageId)?.itemName || "None" : "None" -- cgit v1.2.3