Loading workspaces...
; - } - - if (isError) { - returnError loading workspaces. Please try again later.
; - } + const workspaces = workspacesResponse?.workspaceResponses ?? []; return ( <> diff --git a/frontend/src/pages/WorkspaceBrowseDetail.tsx b/frontend/src/pages/WorkspaceBrowseDetail.tsx index c15a0c6..60833e7 100644 --- a/frontend/src/pages/WorkspaceBrowseDetail.tsx +++ b/frontend/src/pages/WorkspaceBrowseDetail.tsx @@ -3,8 +3,10 @@ import ProjectCard from '@/components/ProjectCard'; import { Smile } from 'lucide-react'; import ProjectCreateModal from '../components/ProjectCreateModal'; import useAuthStore from '@/stores/useAuthStore'; -import { ProjectResponse } from '@/types'; +import { ProjectResponse, ProjectRequest } from '@/types'; import useProjectListQuery from '@/queries/useProjectListQuery'; +import useWorkspaceQuery from '@/queries/useWorkspaceQuery'; +import { useCreateProject } from '@/hooks/useProjectHooks'; import { webPath } from '@/router'; export default function WorkspaceBrowseDetail() { @@ -13,102 +15,111 @@ export default function WorkspaceBrowseDetail() { const { profile } = useAuthStore(); const memberId = profile?.id ?? 0; const navigate = useNavigate(); - // const createProject = useCreateProject(); + const { data: workspaceData } = useWorkspaceQuery(workspaceId, memberId); const { data: projectsResponse, isError } = useProjectListQuery(workspaceId, memberId); + const createProject = useCreateProject(); - const handleCreateProject = (data: { title: string; labelType: 'classification' | 'detection' | 'segmentation' }) => { - console.log(data); - // createProject.mutate( - // { - // workspaceId: workspaceId, - // memberId, - // data: { title: data.title, projectType: data.labelType }, - // }, - // { - // onSuccess: () => { - // console.log('프로젝트가 성공적으로 생성되었습니다.'); - // refetch(); - // }, - // onError: (error) => { - // console.error('프로젝트 생성 실패:', error); - // const errorMessage = error?.response?.data?.message || error.message || '알 수 없는 오류'; - // console.error('프로젝트 생성 실패:', errorMessage); - // }, - // } - // ); + const handleCreateProject = (data: ProjectRequest) => { + createProject.mutate({ + workspaceId, + memberId, + data, + }); }; - // TODO: 반환 형식 반영 projectsResponse?.workspaceResponses => projectResponse const projects: ProjectResponse[] = projectsResponse?.workspaceResponses ?? []; - if (isNaN(workspaceId)) { - return ( -