From 4614210aa9878922cfa1e424ce677ef893a1b6b2 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 29 Sep 2025 13:31:40 +0000 Subject: (대표님) 구매 권한설정, data room 등 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/project/ProjectList.tsx | 221 ++++++++++++++++++++++++------------- 1 file changed, 147 insertions(+), 74 deletions(-) (limited to 'components/project/ProjectList.tsx') diff --git a/components/project/ProjectList.tsx b/components/project/ProjectList.tsx index 4a4f7962..9dec7e77 100644 --- a/components/project/ProjectList.tsx +++ b/components/project/ProjectList.tsx @@ -2,13 +2,12 @@ 'use client'; import { useState, useEffect } from 'react'; -import { useRouter } from 'next/navigation'; import { useForm } from 'react-hook-form'; -import { - Plus, - Folder, - Users, - Globe, +import { + Plus, + Folder, + Users, + Globe, Lock, Crown, Calendar, @@ -34,6 +33,7 @@ import { Switch } from '@/components/ui/switch'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { useToast } from '@/hooks/use-toast'; import { cn } from '@/lib/utils'; +import { useRouter, usePathname } from "next/navigation" interface Project { id: string; @@ -65,11 +65,16 @@ export function ProjectList() { const [viewMode, setViewMode] = useState<'grid' | 'list'>('grid'); const [createDialogOpen, setCreateDialogOpen] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false); - + const pathname = usePathname() + + const internal = pathname?.includes('evcp') + + console.log(projects) + const router = useRouter(); const { toast } = useToast(); - // React Hook Form 설정 + // React Hook Form setup const { register, handleSubmit, @@ -100,8 +105,8 @@ export function ProjectList() { setProjects(data); } catch (error) { toast({ - title: '오류', - description: '프로젝트 목록을 불러올 수 없습니다.', + title: 'Error', + description: 'Unable to load project list.', variant: 'destructive', }); } @@ -116,25 +121,25 @@ export function ProjectList() { body: JSON.stringify(data), }); - if (!response.ok) throw new Error('프로젝트 생성 실패'); + if (!response.ok) throw new Error('Failed to create project'); const project = await response.json(); - + toast({ - title: '성공', - description: '프로젝트가 생성되었습니다.', + title: 'Success', + description: 'Project has been created.', }); setCreateDialogOpen(false); reset(); fetchProjects(); - - // 생성된 프로젝트로 이동 + + // Navigate to created project router.push(`/evcp/data-room/${project.id}`); } catch (error) { toast({ - title: '오류', - description: '프로젝트 생성에 실패했습니다.', + title: 'Error', + description: 'Failed to create project.', variant: 'destructive', }); } finally { @@ -150,19 +155,20 @@ export function ProjectList() { }; const filteredProjects = { - owned: projects.owned?.filter(p => + owned: projects.owned?.filter(p => p.name.toLowerCase().includes(searchQuery.toLowerCase()) - ), - member: projects.member?.filter(p => + ) || [], // Return empty array instead of undefined + member: projects.member?.filter(p => p.name.toLowerCase().includes(searchQuery.toLowerCase()) - ), - public: projects.public?.filter(p => + ) || [], + public: projects.public?.filter(p => p.name.toLowerCase().includes(searchQuery.toLowerCase()) - ), + ) || [], }; + const ProjectCard = ({ project, role }: { project: Project; role?: string }) => ( - router.push(`/evcp/data-room/${project.id}/files`)} > @@ -182,7 +188,7 @@ export function ProjectList() { )} - {project.description || '설명이 없습니다'} + {project.description || 'No description'} @@ -217,26 +223,30 @@ export function ProjectList() { return ( <> - {/* 헤더 */} + {/* Header */}
-

프로젝트

+

Projects

- 파일을 관리하고 팀과 협업하세요 + Manage files and collaborate with your team

- {/* */} + {internal && + + + } +
- {/* 검색 및 필터 */} + {/* Search and Filter */}
setSearchQuery(e.target.value)} @@ -251,22 +261,85 @@ export function ProjectList() {
- {/* 프로젝트 목록 */} + {/* Project List */} + {internal && + + My Projects ({filteredProjects.owned?.length}) + + } + - 참여 프로젝트 ({filteredProjects.member?.length}) + Joined Projects ({filteredProjects.member?.length}) - 공개 프로젝트 ({filteredProjects.public?.length}) + Public Projects ({filteredProjects.public?.length}) + {/* My Projects Tab */} + {internal && + + {filteredProjects.owned?.length === 0 ? ( +
+ +

You don't own any projects

+ +
+ ) : viewMode === 'grid' ? ( +
+ {filteredProjects.owned?.map(project => ( + + ))} +
+ ) : ( +
+ {filteredProjects.owned?.map(project => ( + router.push(`/evcp/data-room/${project.id}/files`)} + > + +
+ +
+

{project.code} {project.name}

+

+ {project.description || 'No description'} +

+
+
+
+ Owner + {project.isPublic ? ( + + ) : ( + + )} +
+
+
+ ))} +
+ )} +
+ + + } + {filteredProjects.member?.length === 0 ? (
-

참여 중인 프로젝트가 없습니다

+

You are not a member of any projects

) : viewMode === 'grid' ? (
@@ -277,7 +350,7 @@ export function ProjectList() { ) : (
{filteredProjects.member?.map(project => ( - router.push(`/evcp/data-room/${project.id}/files`)} @@ -286,9 +359,9 @@ export function ProjectList() {
-

{project.name}

+

{project.code} {project.name}

- {project.description || '설명이 없습니다'} + {project.description || 'No description'}

@@ -311,7 +384,7 @@ export function ProjectList() { {filteredProjects.public?.length === 0 ? (
-

공개 프로젝트가 없습니다

+

No public projects

) : viewMode === 'grid' ? (
@@ -322,7 +395,7 @@ export function ProjectList() { ) : (
{filteredProjects.public?.map(project => ( - router.push(`/evcp/data-room/${project.id}/files`)} @@ -331,13 +404,13 @@ export function ProjectList() {
-

{project.name}

+

{project.code} {project.name}

- {project.description || '설명이 없습니다'} + {project.description || 'No description'}

- 공개 + Public
))} @@ -346,32 +419,32 @@ export function ProjectList() { - {/* 프로젝트 생성 다이얼로그 */} + {/* Create Project Dialog */} - 새 프로젝트 만들기 + Create New Project - 팀과 파일을 공유할 새 프로젝트를 생성합니다 + Create a new project to share files with your team - +
{errors.name && (

{errors.name.message}

)}
- +
- + {errors.description && (

{errors.description.message}

)}
- +
- +

- 모든 사용자가 이 프로젝트를 볼 수 있습니다 + All users can view this project

setValue('isPublic', checked)} />
- + - -
-- cgit v1.2.3