Introduces space entity for page organization
Adds comprehensive space management capabilities, enabling users to organize pages within distinct, self-contained spaces. This change includes: - Introduces a new 'Space' entity with dedicated API endpoints for CRUD operations. - Develops new UI pages for listing all available spaces and for creating new spaces. - Refactors existing page list, detail, and edit views to operate within the context of a specific space, accessed via a `spaceKey` in the URL. - Updates application routing to establish a hierarchical structure, nesting page-related routes under `/spaces/:spaceKey`. - Enhances navigation and breadcrumbs to reflect the current space context.
This commit is contained in:
1 parent
6325f8f109
commit
e5d4ff5866
10 files changed
+463
-36
No files matched your search
+7
-5
@@ -3,7 +3,7 @@ import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
||||
import { MsalProvider } from '@azure/msal-react';
|
||||
import { PublicClientApplication } from '@azure/msal-browser';
|
||||
import { msalConfig } from '../config/authConfig';
|
||||
import { PageListPage, PageDetailPage, PageEditPage, TestApiPage } from '../pages';
|
||||
import { SpaceListPage, SpaceEditPage, PageListPage, PageDetailPage, PageEditPage, TestApiPage } from '../pages';
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
@@ -23,10 +23,12 @@ function App() {
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/" element={<PageListPage />} />
|
||||
<Route path="/pages/new" element={<PageEditPage />} />
|
||||
<Route path="/pages/:id" element={<PageDetailPage />} />
|
||||
<Route path="/pages/:id/edit" element={<PageEditPage />} />
|
||||
<Route path="/" element={<SpaceListPage />} />
|
||||
<Route path="/spaces/new" element={<SpaceEditPage />} />
|
||||
<Route path="/spaces/:spaceKey" element={<PageListPage />} />
|
||||
<Route path="/spaces/:spaceKey/pages/new" element={<PageEditPage />} />
|
||||
<Route path="/spaces/:spaceKey/pages/:id" element={<PageDetailPage />} />
|
||||
<Route path="/spaces/:spaceKey/pages/:id/edit" element={<PageEditPage />} />
|
||||
<Route path="/test-api" element={<TestApiPage />} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
import type { Space, CreateSpaceData, UpdateSpaceData } from './types';
|
||||
import type { ApiClient } from '../../kiota/apiClient';
|
||||
import type { SpaceResponseDto, CreateSpaceDto, UpdateSpaceDto } from '../../kiota/models';
|
||||
import type { Guid } from '@microsoft/kiota-abstractions';
|
||||
|
||||
/**
|
||||
* Convert SpaceResponseDto to local Space type
|
||||
*/
|
||||
function mapSpaceResponseToSpace(dto: SpaceResponseDto): Space {
|
||||
return {
|
||||
id: dto.spaceId?.toString() || '',
|
||||
name: dto.nameEscaped || '',
|
||||
spaceKey: dto.spaceKey || '',
|
||||
description: dto.description?.toString() || null,
|
||||
createdAt: dto.createdAt?.toISOString() || new Date().toISOString(),
|
||||
createdByUserId: dto.createdByUserId?.toString() || '',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all spaces
|
||||
*/
|
||||
export async function getSpaces(apiClient: ApiClient): Promise<Space[]> {
|
||||
const response = await apiClient.v1.space.get();
|
||||
|
||||
if (!response) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return response.map(mapSpaceResponseToSpace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific space by ID
|
||||
*/
|
||||
export async function getSpace(apiClient: ApiClient, spaceId: string): Promise<Space> {
|
||||
const response = await apiClient.v1.space.bySpaceId(spaceId as Guid).get();
|
||||
|
||||
if (!response) {
|
||||
throw new Error(`Space with id ${spaceId} not found`);
|
||||
}
|
||||
|
||||
return mapSpaceResponseToSpace(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a space by spaceKey
|
||||
*/
|
||||
export async function getSpaceByKey(apiClient: ApiClient, spaceKey: string): Promise<Space> {
|
||||
const response = await apiClient.v1.space.key.bySpaceKey(spaceKey).get();
|
||||
|
||||
if (!response) {
|
||||
throw new Error(`Space with key ${spaceKey} not found`);
|
||||
}
|
||||
|
||||
return mapSpaceResponseToSpace(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new space
|
||||
*/
|
||||
export async function createSpace(
|
||||
apiClient: ApiClient,
|
||||
data: CreateSpaceData,
|
||||
userId: string
|
||||
): Promise<Space> {
|
||||
const createDto: CreateSpaceDto = {
|
||||
name: data.name,
|
||||
spaceKey: data.spaceKey,
|
||||
description: data.description,
|
||||
userId: userId as Guid,
|
||||
};
|
||||
|
||||
const response = await apiClient.v1.space.post(createDto);
|
||||
|
||||
if (!response) {
|
||||
throw new Error('Failed to create space');
|
||||
}
|
||||
|
||||
return mapSpaceResponseToSpace(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing space
|
||||
*/
|
||||
export async function updateSpace(
|
||||
apiClient: ApiClient,
|
||||
spaceId: string,
|
||||
data: UpdateSpaceData
|
||||
): Promise<Space> {
|
||||
const updateDto: UpdateSpaceDto = {
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
};
|
||||
|
||||
const response = await apiClient.v1.space.bySpaceId(spaceId as Guid).put(updateDto);
|
||||
|
||||
if (!response) {
|
||||
throw new Error(`Failed to update space ${spaceId}`);
|
||||
}
|
||||
|
||||
return mapSpaceResponseToSpace(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a space
|
||||
*/
|
||||
export async function deleteSpace(
|
||||
apiClient: ApiClient,
|
||||
spaceId: string
|
||||
): Promise<void> {
|
||||
await apiClient.v1.space.bySpaceId(spaceId as Guid).delete();
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './types';
|
||||
export * from './api';
|
||||
@@ -0,0 +1,27 @@
|
||||
export interface Space {
|
||||
id: string;
|
||||
name: string;
|
||||
spaceKey: string;
|
||||
description?: string | null;
|
||||
createdAt: string;
|
||||
createdByUserId: string;
|
||||
}
|
||||
|
||||
export interface CreateSpaceData {
|
||||
name: string;
|
||||
spaceKey: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface UpdateSpaceData {
|
||||
name: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface SpaceStatistics {
|
||||
space: Space;
|
||||
statistics: {
|
||||
pageCount?: number;
|
||||
lastUpdated?: string;
|
||||
};
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import { useState } from 'react';
|
||||
import { useApiClient, useUserId } from '../shared/hooks/useApiClient';
|
||||
|
||||
function PageDetailContent() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const { spaceKey, id } = useParams<{ spaceKey: string; id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const queryClient = useQueryClient();
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
@@ -32,7 +32,7 @@ function PageDetailContent() {
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['pages'] });
|
||||
queryClient.removeQueries({ queryKey: ['page', id] });
|
||||
navigate('/');
|
||||
navigate(`/spaces/${spaceKey}`);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ function PageDetailContent() {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center py-12 space-y-4">
|
||||
<p className="text-red-400">페이지를 찾을 수 없습니다.</p>
|
||||
<Link to="/" className="text-[#4db8ff] hover:text-[#8cd7ff]">
|
||||
<Link to={`/spaces/${spaceKey}`} className="text-[#4db8ff] hover:text-[#8cd7ff]">
|
||||
목록으로 돌아가기
|
||||
</Link>
|
||||
</div>
|
||||
@@ -64,7 +64,8 @@ function PageDetailContent() {
|
||||
<>
|
||||
<Breadcrumb
|
||||
items={[
|
||||
{ label: 'Learn', path: '/' },
|
||||
{ label: 'Spaces', path: '/' },
|
||||
{ label: spaceKey || '', path: `/spaces/${spaceKey}` },
|
||||
{ label: page.title },
|
||||
]}
|
||||
/>
|
||||
@@ -75,7 +76,7 @@ function PageDetailContent() {
|
||||
<h1 className="text-4xl font-bold text-[#e4e4e4] mb-4">{page.title}</h1>
|
||||
<div className="flex gap-3">
|
||||
<Link
|
||||
to={`/pages/${id}/edit`}
|
||||
to={`/spaces/${spaceKey}/pages/${id}/edit`}
|
||||
className="inline-flex items-center gap-2 px-4 py-2 bg-[#2d2d30] border border-[#3e3e42] rounded text-[#e4e4e4] hover:bg-[#3e3e42] transition-colors"
|
||||
>
|
||||
<Pencil1Icon className="h-4 w-4" />
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { getPage, createPage, updatePage } from '../entities/page';
|
||||
import { getSpaceByKey } from '../entities/space';
|
||||
import { PageForm } from '../features/page';
|
||||
import { Layout } from '../shared/Layout';
|
||||
import { Breadcrumb } from '../shared/Breadcrumb';
|
||||
import { useApiClient, useUserId } from '../shared/hooks/useApiClient';
|
||||
|
||||
export function PageEditPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const { spaceKey, id } = useParams<{ spaceKey: string; id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const queryClient = useQueryClient();
|
||||
const isNew = !id;
|
||||
const apiClient = useApiClient();
|
||||
const userId = useUserId();
|
||||
|
||||
// TODO: Get spaceId from context or props - using placeholder for now
|
||||
const spaceId = 'default-space-id'; // This should come from app context or route params
|
||||
const { data: space } = useQuery({
|
||||
queryKey: ['space', spaceKey],
|
||||
queryFn: () => getSpaceByKey(apiClient, spaceKey!),
|
||||
enabled: !!spaceKey,
|
||||
});
|
||||
|
||||
const { data: page, isLoading } = useQuery({
|
||||
queryKey: ['page', id],
|
||||
@@ -26,11 +30,12 @@ export function PageEditPage() {
|
||||
const createMutation = useMutation({
|
||||
mutationFn: (data: { title: string; content: string }) => {
|
||||
if (!userId) throw new Error('User not authenticated');
|
||||
return createPage(apiClient, data, userId, spaceId);
|
||||
if (!space?.id) throw new Error('Space not found');
|
||||
return createPage(apiClient, data, userId, space.id);
|
||||
},
|
||||
onSuccess: (newPage) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['pages'] });
|
||||
navigate(`/pages/${newPage.id}`);
|
||||
queryClient.invalidateQueries({ queryKey: ['pages', space?.id] });
|
||||
navigate(`/spaces/${spaceKey}/pages/${newPage.id}`);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -41,8 +46,8 @@ export function PageEditPage() {
|
||||
},
|
||||
onSuccess: (updatedPage) => {
|
||||
queryClient.setQueryData(['page', id], updatedPage);
|
||||
queryClient.invalidateQueries({ queryKey: ['pages'] });
|
||||
navigate(`/pages/${id}`);
|
||||
queryClient.invalidateQueries({ queryKey: ['pages', space?.id] });
|
||||
navigate(`/spaces/${spaceKey}/pages/${id}`);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -74,7 +79,8 @@ export function PageEditPage() {
|
||||
<Layout>
|
||||
<Breadcrumb
|
||||
items={[
|
||||
{ label: 'Learn', path: '/' },
|
||||
{ label: 'Spaces', path: '/' },
|
||||
{ label: space?.name || spaceKey || '', path: `/spaces/${spaceKey}` },
|
||||
{ label: isNew ? '새 페이지 만들기' : page?.title || '편집' },
|
||||
]}
|
||||
/>
|
||||
|
||||
+56
-13
@@ -1,19 +1,31 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Link, useParams } from 'react-router-dom';
|
||||
import { getPages } from '../entities/page';
|
||||
import { getSpaceByKey } from '../entities/space';
|
||||
import { Layout } from '../shared/Layout';
|
||||
import { Breadcrumb } from '../shared/Breadcrumb';
|
||||
import { FileTextIcon } from '@radix-ui/react-icons';
|
||||
import { FileTextIcon, PlusIcon } from '@radix-ui/react-icons';
|
||||
import { useApiClient } from '../shared/hooks/useApiClient';
|
||||
|
||||
export function PageListPage() {
|
||||
const { spaceKey } = useParams<{ spaceKey: string }>();
|
||||
const apiClient = useApiClient();
|
||||
|
||||
const { data: pages = [], isLoading, error } = useQuery({
|
||||
queryKey: ['pages'],
|
||||
queryFn: () => getPages(apiClient),
|
||||
const { data: space, isLoading: isLoadingSpace, error: spaceError } = useQuery({
|
||||
queryKey: ['space', spaceKey],
|
||||
queryFn: () => getSpaceByKey(apiClient, spaceKey!),
|
||||
enabled: !!spaceKey,
|
||||
});
|
||||
|
||||
const { data: pages = [], isLoading: isLoadingPages, error: pagesError } = useQuery({
|
||||
queryKey: ['pages', space?.id],
|
||||
queryFn: () => getPages(apiClient, space!.id),
|
||||
enabled: !!space?.id,
|
||||
});
|
||||
|
||||
const isLoading = isLoadingSpace || isLoadingPages;
|
||||
const error = spaceError || pagesError;
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<Layout showSidebar={false}>
|
||||
@@ -34,21 +46,50 @@ export function PageListPage() {
|
||||
);
|
||||
}
|
||||
|
||||
if (!space && !isLoading) {
|
||||
return (
|
||||
<Layout showSidebar={false}>
|
||||
<div className="flex flex-col items-center justify-center py-12 space-y-4">
|
||||
<p className="text-red-400">스페이스를 찾을 수 없습니다.</p>
|
||||
<Link to="/" className="text-[#4db8ff] hover:text-[#8cd7ff]">
|
||||
스페이스 목록으로 돌아가기
|
||||
</Link>
|
||||
</div>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Layout showSidebar={false}>
|
||||
<Breadcrumb items={[{ label: 'Learn' }]} />
|
||||
<Breadcrumb
|
||||
items={[
|
||||
{ label: 'Spaces', path: '/' },
|
||||
{ label: space?.name || spaceKey || '' },
|
||||
]}
|
||||
/>
|
||||
|
||||
<div className="max-w-5xl">
|
||||
<h1 className="text-4xl font-bold text-[#e4e4e4] mb-2">위키 페이지</h1>
|
||||
<p className="text-[#9d9d9d] mb-8">
|
||||
모든 문서를 찾아보세요. 왼쪽 사이드바에서 검색하거나 아래 목록을 탐색할 수 있습니다.
|
||||
</p>
|
||||
<div className="flex items-center justify-between mb-8">
|
||||
<div>
|
||||
<h1 className="text-4xl font-bold text-[#e4e4e4] mb-2">{space?.name}</h1>
|
||||
{space?.description && (
|
||||
<p className="text-[#9d9d9d]">{space.description}</p>
|
||||
)}
|
||||
</div>
|
||||
<Link
|
||||
to={`/spaces/${spaceKey}/pages/new`}
|
||||
className="inline-flex items-center gap-2 px-4 py-2 bg-[#0078d4] hover:bg-[#106ebe] text-white rounded transition-colors"
|
||||
>
|
||||
<PlusIcon className="h-4 w-4" />
|
||||
새 페이지
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||
{pages.map((page) => (
|
||||
<Link
|
||||
key={page.id}
|
||||
to={`/pages/${page.id}`}
|
||||
to={`/spaces/${spaceKey}/pages/${page.id}`}
|
||||
className="block p-5 bg-[#252526] border border-[#3e3e42] rounded-lg hover:border-[#0078d4] hover:shadow-lg transition-all"
|
||||
>
|
||||
<div className="flex items-start gap-3">
|
||||
@@ -66,13 +107,15 @@ export function PageListPage() {
|
||||
))}
|
||||
</div>
|
||||
|
||||
{pages.length === 0 && (
|
||||
{pages.length === 0 && !isLoading && (
|
||||
<div className="text-center py-12">
|
||||
<FileTextIcon className="h-16 w-16 text-[#3e3e42] mx-auto mb-4" />
|
||||
<p className="text-[#9d9d9d] mb-4">아직 페이지가 없습니다.</p>
|
||||
<Link
|
||||
to="/pages/new"
|
||||
to={`/spaces/${spaceKey}/pages/new`}
|
||||
className="inline-flex items-center gap-2 px-4 py-2 bg-[#0078d4] hover:bg-[#106ebe] text-white rounded transition-colors"
|
||||
>
|
||||
<PlusIcon className="h-4 w-4" />
|
||||
첫 페이지 만들기
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
import { useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { createSpace } from '../entities/space';
|
||||
import { Layout } from '../shared/Layout';
|
||||
import { Breadcrumb } from '../shared/Breadcrumb';
|
||||
import { useApiClient, useUserId } from '../shared/hooks/useApiClient';
|
||||
|
||||
export function SpaceEditPage() {
|
||||
const navigate = useNavigate();
|
||||
const queryClient = useQueryClient();
|
||||
const apiClient = useApiClient();
|
||||
const userId = useUserId();
|
||||
|
||||
const [formData, setFormData] = useState({
|
||||
name: '',
|
||||
spaceKey: '',
|
||||
description: '',
|
||||
});
|
||||
|
||||
const createMutation = useMutation({
|
||||
mutationFn: (data: { name: string; spaceKey: string; description?: string }) => {
|
||||
if (!userId) throw new Error('User not authenticated');
|
||||
return createSpace(apiClient, data, userId);
|
||||
},
|
||||
onSuccess: (newSpace) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['spaces'] });
|
||||
navigate(`/spaces/${newSpace.spaceKey}`);
|
||||
},
|
||||
});
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
createMutation.mutate(formData);
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
navigate('/');
|
||||
};
|
||||
|
||||
return (
|
||||
<Layout showSidebar={false}>
|
||||
<Breadcrumb
|
||||
items={[
|
||||
{ label: 'Spaces', path: '/' },
|
||||
{ label: '새 스페이스 만들기' },
|
||||
]}
|
||||
/>
|
||||
|
||||
<div className="max-w-2xl">
|
||||
<h1 className="text-4xl font-bold text-[#e4e4e4] mb-8">새 스페이스 만들기</h1>
|
||||
|
||||
<form onSubmit={handleSubmit} className="space-y-6">
|
||||
<div>
|
||||
<label htmlFor="name" className="block text-sm font-medium text-[#e4e4e4] mb-2">
|
||||
스페이스 이름 <span className="text-red-400">*</span>
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
id="name"
|
||||
required
|
||||
value={formData.name}
|
||||
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
|
||||
className="w-full px-4 py-2 bg-[#1e1e1e] border border-[#3e3e42] rounded text-[#e4e4e4] focus:outline-none focus:border-[#0078d4]"
|
||||
placeholder="예: 개발 문서"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label htmlFor="spaceKey" className="block text-sm font-medium text-[#e4e4e4] mb-2">
|
||||
스페이스 키 <span className="text-red-400">*</span>
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
id="spaceKey"
|
||||
required
|
||||
value={formData.spaceKey}
|
||||
onChange={(e) => setFormData({ ...formData, spaceKey: e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, '') })}
|
||||
className="w-full px-4 py-2 bg-[#1e1e1e] border border-[#3e3e42] rounded text-[#e4e4e4] focus:outline-none focus:border-[#0078d4] font-mono"
|
||||
placeholder="예: dev-docs"
|
||||
/>
|
||||
<p className="mt-1 text-xs text-[#9d9d9d]">
|
||||
URL에 사용됩니다. 영문 소문자, 숫자, 하이픈만 사용 가능합니다.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label htmlFor="description" className="block text-sm font-medium text-[#e4e4e4] mb-2">
|
||||
설명
|
||||
</label>
|
||||
<textarea
|
||||
id="description"
|
||||
value={formData.description}
|
||||
onChange={(e) => setFormData({ ...formData, description: e.target.value })}
|
||||
rows={4}
|
||||
className="w-full px-4 py-2 bg-[#1e1e1e] border border-[#3e3e42] rounded text-[#e4e4e4] focus:outline-none focus:border-[#0078d4] resize-none"
|
||||
placeholder="이 스페이스에 대한 간단한 설명을 입력하세요"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{createMutation.error && (
|
||||
<div className="p-4 bg-red-900/20 border border-red-500/50 rounded">
|
||||
<p className="text-sm text-red-400">
|
||||
{(createMutation.error as Error).message}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex gap-3">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={createMutation.isPending || !formData.name || !formData.spaceKey}
|
||||
className="px-6 py-2 bg-[#0078d4] hover:bg-[#106ebe] text-white rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
{createMutation.isPending ? '생성 중...' : '스페이스 만들기'}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleCancel}
|
||||
disabled={createMutation.isPending}
|
||||
className="px-6 py-2 bg-[#2d2d30] border border-[#3e3e42] rounded text-[#e4e4e4] hover:bg-[#3e3e42] transition-colors disabled:opacity-50"
|
||||
>
|
||||
취소
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { getSpaces } from '../entities/space';
|
||||
import { Layout } from '../shared/Layout';
|
||||
import { Breadcrumb } from '../shared/Breadcrumb';
|
||||
import { Component2Icon, PlusIcon } from '@radix-ui/react-icons';
|
||||
import { useApiClient } from '../shared/hooks/useApiClient';
|
||||
|
||||
export function SpaceListPage() {
|
||||
const apiClient = useApiClient();
|
||||
|
||||
const { data: spaces = [], isLoading, error } = useQuery({
|
||||
queryKey: ['spaces'],
|
||||
queryFn: () => getSpaces(apiClient),
|
||||
});
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<Layout showSidebar={false}>
|
||||
<div className="flex justify-center items-center py-12">
|
||||
<p className="text-[#9d9d9d]">불러오는 중...</p>
|
||||
</div>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<Layout showSidebar={false}>
|
||||
<div className="flex justify-center items-center py-12">
|
||||
<p className="text-red-400">오류가 발생했습니다: {(error as Error).message}</p>
|
||||
</div>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Layout showSidebar={false}>
|
||||
<Breadcrumb items={[{ label: 'Spaces' }]} />
|
||||
|
||||
<div className="max-w-5xl">
|
||||
<div className="flex items-center justify-between mb-8">
|
||||
<div>
|
||||
<h1 className="text-4xl font-bold text-[#e4e4e4] mb-2">스페이스</h1>
|
||||
<p className="text-[#9d9d9d]">
|
||||
모든 스페이스를 찾아보세요. 각 스페이스는 독립적인 문서 공간입니다.
|
||||
</p>
|
||||
</div>
|
||||
<Link
|
||||
to="/spaces/new"
|
||||
className="inline-flex items-center gap-2 px-4 py-2 bg-[#0078d4] hover:bg-[#106ebe] text-white rounded transition-colors"
|
||||
>
|
||||
<PlusIcon className="h-4 w-4" />
|
||||
새 스페이스
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||
{spaces.map((space) => (
|
||||
<Link
|
||||
key={space.id}
|
||||
to={`/spaces/${space.spaceKey}`}
|
||||
className="block p-5 bg-[#252526] border border-[#3e3e42] rounded-lg hover:border-[#0078d4] hover:shadow-lg transition-all"
|
||||
>
|
||||
<div className="flex items-start gap-3">
|
||||
<Component2Icon className="h-6 w-6 text-[#0078d4] flex-shrink-0 mt-1" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<h3 className="text-lg font-semibold text-[#e4e4e4] mb-1 truncate">
|
||||
{space.name}
|
||||
</h3>
|
||||
<p className="text-xs text-[#9d9d9d] mb-2 font-mono">
|
||||
{space.spaceKey}
|
||||
</p>
|
||||
{space.description && (
|
||||
<p className="text-sm text-[#9d9d9d] line-clamp-2">
|
||||
{space.description}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{spaces.length === 0 && (
|
||||
<div className="text-center py-12">
|
||||
<Component2Icon className="h-16 w-16 text-[#3e3e42] mx-auto mb-4" />
|
||||
<p className="text-[#9d9d9d] mb-4">아직 스페이스가 없습니다.</p>
|
||||
<Link
|
||||
to="/spaces/new"
|
||||
className="inline-flex items-center gap-2 px-4 py-2 bg-[#0078d4] hover:bg-[#106ebe] text-white rounded transition-colors"
|
||||
>
|
||||
<PlusIcon className="h-4 w-4" />
|
||||
첫 스페이스 만들기
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
+6
-4
@@ -1,4 +1,6 @@
|
||||
export * from './PageListPage';
|
||||
export * from './PageDetailPage';
|
||||
export * from './PageEditPage';
|
||||
export * from './TestApiPage';
|
||||
export { SpaceListPage } from './SpaceListPage';
|
||||
export { SpaceEditPage } from './SpaceEditPage';
|
||||
export { PageListPage } from './PageListPage';
|
||||
export { PageDetailPage } from './PageDetailPage';
|
||||
export { PageEditPage } from './PageEditPage';
|
||||
export { TestApiPage } from './TestApiPage';
|
||||
Reference in new issue
Block a user