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>
74 lines
1.7 KiB
TypeScript
74 lines
1.7 KiB
TypeScript
/**
|
|
* Session ratings localStorage helper
|
|
* Tracks which sessions have already been rated to prevent repeat prompts
|
|
*/
|
|
|
|
const STORAGE_KEY = 'patherly_rated_sessions'
|
|
|
|
interface RatedSessionsData {
|
|
[sessionId: string]: {
|
|
ratedAt: string // ISO timestamp
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Check if a session has already been rated
|
|
*/
|
|
export function hasRatedSession(sessionId: string): boolean {
|
|
try {
|
|
const data = localStorage.getItem(STORAGE_KEY)
|
|
if (!data) return false
|
|
|
|
const rated: RatedSessionsData = JSON.parse(data)
|
|
return sessionId in rated
|
|
} catch (error) {
|
|
console.error('Error checking rated sessions:', error)
|
|
return false
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Mark a session as rated
|
|
*/
|
|
export function markSessionRated(sessionId: string): void {
|
|
try {
|
|
const data = localStorage.getItem(STORAGE_KEY)
|
|
const rated: RatedSessionsData = data ? JSON.parse(data) : {}
|
|
|
|
rated[sessionId] = {
|
|
ratedAt: new Date().toISOString()
|
|
}
|
|
|
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(rated))
|
|
} catch (error) {
|
|
console.error('Error marking session as rated:', error)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Clear all rated session tracking (for testing/debugging)
|
|
*/
|
|
export function clearRatedSessions(): void {
|
|
try {
|
|
localStorage.removeItem(STORAGE_KEY)
|
|
} catch (error) {
|
|
console.error('Error clearing rated sessions:', error)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get all rated session IDs
|
|
*/
|
|
export function getRatedSessions(): string[] {
|
|
try {
|
|
const data = localStorage.getItem(STORAGE_KEY)
|
|
if (!data) return []
|
|
|
|
const rated: RatedSessionsData = JSON.parse(data)
|
|
return Object.keys(rated)
|
|
} catch (error) {
|
|
console.error('Error getting rated sessions:', error)
|
|
return []
|
|
}
|
|
}
|