From b12a06766e32e3c76544b1d12bec91653e1fe9db Mon Sep 17 00:00:00 2001 From: 0-Zz-ang Date: Mon, 25 Aug 2025 09:23:30 +0900 Subject: docu-list-rule페이지 수정 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../docu-list-rule/docu-list-rule-client.tsx | 141 +++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 components/docu-list-rule/docu-list-rule-client.tsx (limited to 'components/docu-list-rule/docu-list-rule-client.tsx') diff --git a/components/docu-list-rule/docu-list-rule-client.tsx b/components/docu-list-rule/docu-list-rule-client.tsx new file mode 100644 index 00000000..7e6c2bb1 --- /dev/null +++ b/components/docu-list-rule/docu-list-rule-client.tsx @@ -0,0 +1,141 @@ +"use client" +import * as React from "react" +import { useRouter, useParams } from "next/navigation" + +import { getProjectLists } from "@/lib/projects/service" +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select" + +interface DocuListRuleClientProps { + children: React.ReactNode +} + +export default function DocuListRuleClient({ + children, +}: DocuListRuleClientProps) { + const router = useRouter() + const params = useParams() + const lng = (params?.lng as string) || "ko" + + // Get the projectId from route parameters + const projectIdFromUrl = React.useMemo(() => { + if (params?.projectId) { + const projectId = Array.isArray(params.projectId) + ? params.projectId[0] + : params.projectId + return Number(projectId) + } + return null + }, [params]) + + // Use the URL projectId as the selected project + const [selectedProjectId, setSelectedProjectId] = React.useState( + projectIdFromUrl + ) + + // 프로젝트 목록 상태 + const [projects, setProjects] = React.useState>([]) + const [isLoading, setIsLoading] = React.useState(true) + + // Update selectedProjectId when URL changes + React.useEffect(() => { + if (projectIdFromUrl) { + setSelectedProjectId(projectIdFromUrl) + } + }, [projectIdFromUrl]) + + // 프로젝트 목록 로드 + React.useEffect(() => { + const loadProjects = async () => { + try { + setIsLoading(true) + console.log("Loading projects...") + const result = await getProjectLists({ + page: 1, + perPage: 1000, + search: "", + sort: [], + filters: [], + joinOperator: "and", + flags: [], + code: "", + name: "", + type: "" + }) + console.log("Projects result:", result) + if (result.data) { + // plant 타입의 프로젝트만 필터링 + const plantProjects = result.data.filter(project => project.type === 'plant') + console.log("Plant projects:", plantProjects) + setProjects(plantProjects) + } + } catch (error) { + console.error("Failed to load projects:", error) + } finally { + setIsLoading(false) + } + } + loadProjects() + }, []) + + // Handle project selection + function handleSelectProject(projectId: number) { + console.log("Selecting project:", projectId) + setSelectedProjectId(projectId) + + // Navigate to the project's document-class page + router.push(`/${lng}/evcp/docu-list-rule/${projectId}`) + } + + return ( + <> + {/* 상단 영역: 제목 왼쪽 / ProjectSwitcher 오른쪽 */} +
+ {/* 왼쪽: 타이틀 & 설명 */} +
+
+

Document Numbering Rule (해양)

+
+

+ 벤더 제출 문서 리스트 작성 시에 사용되는 넘버링 +

+
+ + {/* 오른쪽: ProjectSwitcher */} +
+ +
+
+ + {/* 문서 목록/테이블 영역 */} +
+ {children} +
+ + ) +} -- cgit v1.2.3