From f7f5069a2209cfa39b65f492f32270a5f554bed0 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Thu, 23 Oct 2025 10:10:21 +0000 Subject: (대표님) EDP 해양 관련 개발 사항들 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/vendor-data/sidebar.tsx | 175 +++++++++++++++++-------------------- 1 file changed, 80 insertions(+), 95 deletions(-) (limited to 'components/vendor-data') diff --git a/components/vendor-data/sidebar.tsx b/components/vendor-data/sidebar.tsx index 2e633442..edaf2e25 100644 --- a/components/vendor-data/sidebar.tsx +++ b/components/vendor-data/sidebar.tsx @@ -10,7 +10,7 @@ import { TooltipTrigger, TooltipContent, } from "@/components/ui/tooltip" -import { Package2, FormInput, ChevronRight, ChevronDown } from "lucide-react" +import { Package2, FormInput } from "lucide-react" import { useRouter, usePathname } from "next/navigation" import { Skeleton } from "@/components/ui/skeleton" import { type FormInfo } from "@/lib/forms/services" @@ -49,9 +49,6 @@ export function Sidebar({ const router = useRouter() const rawPathname = usePathname() const pathname = rawPathname ?? "" - - // ENG 모드에서 각 폼의 확장/축소 상태 관리 - const [expandedForms, setExpandedForms] = React.useState>(new Set()) /** * --------------------------- @@ -87,33 +84,28 @@ export function Sidebar({ * --------------------------- */ const handlePackageClick = (itemId: number) => { + // 상위 컴포넌트 상태 업데이트 onSelectPackage(itemId) + + // 해당 태그 페이지로 라우팅 + // 예: /vendor-data/tag/123 + const baseSegments = segments.slice(0, segments.indexOf("vendor-data") + 1).join("/") + router.push(`/${baseSegments}/tag/${itemId}`) } /** * --------------------------- - * 3) 폼 클릭 핸들러 (IM 모드) + * 3) 폼 클릭 핸들러 (IM 모드만 사용) * --------------------------- */ const handleFormClick = (form: FormInfo) => { - if (mode === "IM") { - // IM 모드에서는 반드시 선택된 패키지 ID 필요 - if (selectedPackageId === null) return; - - onSelectForm(form.formName) - - const baseSegments = segments.slice(0, segments.indexOf("vendor-data") + 1).join("/") - router.push(`/${baseSegments}/form/${selectedPackageId}/${form.formCode}/${selectedProjectId}/${selectedContractId}?mode=${mode}`) - } else { - // ENG 모드에서는 폼을 클릭하면 확장/축소만 토글 - const newExpanded = new Set(expandedForms) - if (newExpanded.has(form.formCode)) { - newExpanded.delete(form.formCode) - } else { - newExpanded.add(form.formCode) - } - setExpandedForms(newExpanded) - } + // IM 모드에서만 사용 + if (selectedPackageId === null) return; + + onSelectForm(form.formName) + + const baseSegments = segments.slice(0, segments.indexOf("vendor-data") + 1).join("/") + router.push(`/${baseSegments}/form/${selectedPackageId}/${form.formCode}/${selectedProjectId}/${selectedContractId}?mode=${mode}`) } /** @@ -187,10 +179,13 @@ export function Sidebar({ )} - {/* ---------- 폼 목록 (IM 모드) / 폼과 패키지 목록 (ENG 모드) ---------- */} + {/* ---------- 폼 목록 (IM 모드) / 패키지와 폼 목록 (ENG 모드) ---------- */}

- {isCollapsed ? "F" : "Form Lists"} + {isCollapsed + ? (mode === "IM" ? "F" : "P") + : (mode === "IM" ? "Form Lists" : "Package Lists") + }

)) - ) : !forms || forms.length === 0 ? ( -

- (No forms loaded) -

- ) : ( - forms.map((form) => { - const isFormActive = form.formCode === currentFormCode - const isExpanded = expandedForms.has(form.formCode) - - // IM 모드 - if (mode === "IM") { + ) : mode === "IM" ? ( + // =========== IM 모드: 폼만 표시 =========== + !forms || forms.length === 0 ? ( +

+ (No forms loaded) +

+ ) : ( + forms.map((form) => { + const isFormActive = form.formCode === currentFormCode const isDisabled = currentItemId === null return isCollapsed ? ( @@ -250,79 +243,71 @@ export function Sidebar({ {form.formName} ) - } - - // ENG 모드 - 폼과 그 아래 패키지들 표시 - return ( -
+ }) + ) + ) : ( + // =========== ENG 모드: 패키지 > 폼 계층 구조 =========== + packages.length === 0 ? ( +

+ (No packages loaded) +

+ ) : ( + packages.map((pkg) => ( +
{isCollapsed ? ( - +
+ +
- {form.formName} + {pkg.itemName}
) : ( <> - + {/* 패키지 이름 (클릭 불가능한 라벨) */} +
+ + {pkg.itemName} +
- {/* 확장된 경우 패키지 목록 표시 */} - {isExpanded && ( -
- {packages.length === 0 ? ( -

- No packages available -

- ) : ( - packages.map((pkg) => { - const isPackageActive = - pkg.itemId === currentItemId && - form.formCode === currentFormCode + {/* 폼 목록 바로 표시 */} +
+ {!forms || forms.length === 0 ? ( +

+ No forms available +

+ ) : ( + forms.map((form) => { + const isFormPackageActive = + pkg.itemId === currentItemId && + form.formCode === currentFormCode - return ( - - ) - }) - )} -
- )} + return ( + + ) + }) + )} +
)}
- ) - }) + )) + ) )}
-- cgit v1.2.3