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:
Michael Chihlas
2026-02-07 23:06:46 -05:00
parent c7b2c59ef6
commit 996b664ca9
30 changed files with 2973 additions and 92 deletions

View File

@@ -1,18 +1,24 @@
import { createBrowserRouter, Navigate } from 'react-router-dom'
import { lazy, Suspense } from 'react'
import { AppLayout, ProtectedRoute } from '@/components/layout'
import { RouteError } from '@/components/common/RouteError'
import { PageLoader } from '@/components/common/PageLoader'
import {
LoginPage,
RegisterPage,
TreeLibraryPage,
TreeNavigationPage,
TreeEditorPage,
SessionHistoryPage,
SessionDetailPage,
SettingsPage,
AccountSettingsPage,
} from '@/pages'
// Lazy load heavy pages for code splitting
const TreeLibraryPage = lazy(() => import('@/pages/TreeLibraryPage'))
const MyTreesPage = lazy(() => import('@/pages/MyTreesPage'))
const TreeNavigationPage = lazy(() => import('@/pages/TreeNavigationPage'))
const TreeEditorPage = lazy(() => import('@/pages/TreeEditorPage'))
const SessionHistoryPage = lazy(() => import('@/pages/SessionHistoryPage'))
const SessionDetailPage = lazy(() => import('@/pages/SessionDetailPage'))
const SettingsPage = lazy(() => import('@/pages/SettingsPage'))
const AccountSettingsPage = lazy(() => import('@/pages/AccountSettingsPage'))
const AdminCategoriesPage = lazy(() => import('@/pages/AdminCategoriesPage'))
export const router = createBrowserRouter([
{
path: '/login',
@@ -39,35 +45,85 @@ export const router = createBrowserRouter([
},
{
path: 'trees',
element: <TreeLibraryPage />,
element: (
<Suspense fallback={<PageLoader />}>
<TreeLibraryPage />
</Suspense>
),
},
{
path: 'my-trees',
element: (
<Suspense fallback={<PageLoader />}>
<MyTreesPage />
</Suspense>
),
},
{
path: 'trees/new',
element: <TreeEditorPage />,
element: (
<Suspense fallback={<PageLoader />}>
<TreeEditorPage />
</Suspense>
),
},
{
path: 'trees/:id/edit',
element: <TreeEditorPage />,
element: (
<Suspense fallback={<PageLoader />}>
<TreeEditorPage />
</Suspense>
),
},
{
path: 'trees/:id/navigate',
element: <TreeNavigationPage />,
element: (
<Suspense fallback={<PageLoader />}>
<TreeNavigationPage />
</Suspense>
),
},
{
path: 'sessions',
element: <SessionHistoryPage />,
element: (
<Suspense fallback={<PageLoader />}>
<SessionHistoryPage />
</Suspense>
),
},
{
path: 'sessions/:id',
element: <SessionDetailPage />,
element: (
<Suspense fallback={<PageLoader />}>
<SessionDetailPage />
</Suspense>
),
},
{
path: 'settings',
element: <SettingsPage />,
element: (
<Suspense fallback={<PageLoader />}>
<SettingsPage />
</Suspense>
),
},
{
path: 'account',
element: <AccountSettingsPage />,
element: (
<Suspense fallback={<PageLoader />}>
<AccountSettingsPage />
</Suspense>
),
},
{
path: 'admin/categories',
element: (
<Suspense fallback={<PageLoader />}>
<ProtectedRoute requiredRole="super_admin">
<AdminCategoriesPage />
</ProtectedRoute>
</Suspense>
),
},
],
},