feat: implement My Trees, admin UI, rating modal, and bundle optimization (Issues #15, #18, #19, #31)
Frontend features: - My Trees personal dashboard with fork tracking (Issue #15) - Tree sharing UI with token generation and copy (Issue #16) - Draft tree badges and validation UI (Issue #25) - Save session as tree modal (Issue #17) - Rate/review modal with localStorage tracking (Issue #19) - Admin category management with drag-and-drop (Issue #18) - Bundle size optimization with code splitting (Issue #31) Components created: - MyTreesPage: Personal tree organization - AdminCategoriesPage: Category CRUD with @dnd-kit - ShareTreeModal: Tree sharing interface - SaveSessionAsTreeModal: Session conversion UI - StepRatingModal: Post-session rating with stars - StarRating: Reusable rating component - PageLoader: Loading fallback for lazy routes - CreateCategoryModal, EditCategoryModal: Admin modals Bundle optimization: - Reduced from 892 KB to 221 KB (75% reduction) - Dynamic imports for 9 heavy pages - Vendor chunk splitting for optimal caching - 6 separate vendor chunks (react, markdown, utils, dnd, icons, state) Dependencies added: - @dnd-kit/core, @dnd-kit/sortable, @dnd-kit/utilities API clients: - stepCategories: Full CRUD for admin - Enhanced sessions: saveAsTree endpoint - Enhanced trees: share, fork, canPublish endpoints Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import apiClient from './client'
|
||||
import type { Session, SessionCreate, SessionUpdate, SessionExport } from '@/types'
|
||||
import type { Session, SessionCreate, SessionUpdate, SessionExport, SaveAsTreeRequest, SaveAsTreeResponse } from '@/types'
|
||||
|
||||
export interface SessionListParams {
|
||||
page?: number
|
||||
@@ -58,6 +58,11 @@ export const sessionsApi = {
|
||||
const response = await apiClient.patch<Session>(`/sessions/${id}/scratchpad`, { scratchpad: content })
|
||||
return response.data
|
||||
},
|
||||
|
||||
async saveAsTree(id: string, data: SaveAsTreeRequest): Promise<SaveAsTreeResponse> {
|
||||
const response = await apiClient.post<SaveAsTreeResponse>(`/sessions/${id}/save-as-tree`, data)
|
||||
return response.data
|
||||
},
|
||||
}
|
||||
|
||||
export default sessionsApi
|
||||
|
||||
@@ -1,15 +1,62 @@
|
||||
import apiClient from './client'
|
||||
import type { StepCategory } from '@/types/step'
|
||||
import type {
|
||||
StepCategory,
|
||||
StepCategoryListItem,
|
||||
StepCategoryCreate,
|
||||
StepCategoryUpdate
|
||||
} from '@/types'
|
||||
|
||||
export interface StepCategoryListParams {
|
||||
include_inactive?: boolean
|
||||
account_only?: boolean
|
||||
}
|
||||
|
||||
export const stepCategoriesApi = {
|
||||
async list(): Promise<StepCategory[]> {
|
||||
const response = await apiClient.get<StepCategory[]>('/step-categories')
|
||||
async list(params?: StepCategoryListParams): Promise<StepCategoryListItem[]> {
|
||||
const response = await apiClient.get<StepCategoryListItem[]>('/step-categories', { params })
|
||||
return response.data
|
||||
},
|
||||
|
||||
async get(id: string): Promise<StepCategory> {
|
||||
const response = await apiClient.get<StepCategory>(`/step-categories/${id}`)
|
||||
return response.data
|
||||
},
|
||||
|
||||
async create(data: StepCategoryCreate): Promise<StepCategory> {
|
||||
const response = await apiClient.post<StepCategory>('/step-categories', data)
|
||||
return response.data
|
||||
},
|
||||
|
||||
async update(id: string, data: StepCategoryUpdate): Promise<StepCategory> {
|
||||
const response = await apiClient.put<StepCategory>(`/step-categories/${id}`, data)
|
||||
return response.data
|
||||
},
|
||||
|
||||
async delete(id: string): Promise<void> {
|
||||
await apiClient.delete(`/step-categories/${id}`)
|
||||
},
|
||||
|
||||
async archive(id: string): Promise<StepCategory> {
|
||||
const response = await apiClient.put<StepCategory>(`/step-categories/${id}`, {
|
||||
is_active: false
|
||||
})
|
||||
return response.data
|
||||
},
|
||||
|
||||
async restore(id: string): Promise<StepCategory> {
|
||||
const response = await apiClient.put<StepCategory>(`/step-categories/${id}`, {
|
||||
is_active: true
|
||||
})
|
||||
return response.data
|
||||
},
|
||||
|
||||
async updateOrder(updates: Array<{ id: string; display_order: number }>): Promise<void> {
|
||||
// Update display_order for multiple categories
|
||||
await Promise.all(
|
||||
updates.map(({ id, display_order }) =>
|
||||
apiClient.put(`/step-categories/${id}`, { display_order })
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import apiClient from './client'
|
||||
import type { Tree, TreeListItem, TreeCreate, TreeUpdate, TreeFilters } from '@/types'
|
||||
import type { Tree, TreeListItem, TreeCreate, TreeUpdate, TreeFilters, TreeShareCreate, TreeShare, TreeVisibilityUpdate, SharedTree, TreeValidationResponse } from '@/types'
|
||||
|
||||
export const treesApi = {
|
||||
async list(params?: TreeFilters): Promise<TreeListItem[]> {
|
||||
@@ -38,6 +38,38 @@ export const treesApi = {
|
||||
})
|
||||
return response.data
|
||||
},
|
||||
|
||||
async fork(id: string, data?: { fork_reason?: string; name?: string }): Promise<Tree> {
|
||||
const response = await apiClient.post<Tree>(`/trees/${id}/fork`, data || {})
|
||||
return response.data
|
||||
},
|
||||
|
||||
// Tree sharing
|
||||
async createShare(id: string, data: TreeShareCreate): Promise<TreeShare> {
|
||||
const response = await apiClient.post<TreeShare>(`/trees/${id}/share`, data)
|
||||
return response.data
|
||||
},
|
||||
|
||||
async listShares(id: string): Promise<TreeShare[]> {
|
||||
const response = await apiClient.get<TreeShare[]>(`/trees/${id}/shares`)
|
||||
return response.data
|
||||
},
|
||||
|
||||
async updateVisibility(id: string, data: TreeVisibilityUpdate): Promise<Tree> {
|
||||
const response = await apiClient.patch<Tree>(`/trees/${id}/visibility`, data)
|
||||
return response.data
|
||||
},
|
||||
|
||||
async getSharedTree(shareToken: string): Promise<SharedTree> {
|
||||
const response = await apiClient.get<SharedTree>(`/shared/${shareToken}`)
|
||||
return response.data
|
||||
},
|
||||
|
||||
// Tree validation
|
||||
async canPublish(id: string): Promise<TreeValidationResponse> {
|
||||
const response = await apiClient.post<TreeValidationResponse>(`/trees/${id}/can-publish`)
|
||||
return response.data
|
||||
},
|
||||
}
|
||||
|
||||
export default treesApi
|
||||
|
||||
Reference in New Issue
Block a user