# Dashboard Migration Summary ## Migration Date 2025-11-10 ## Source From: `/Users/byeongcheolryu/codebridgex/sam_project/sam-react` (Vite React) To: `/Users/byeongcheolryu/codebridgex/sam_project/sam-next/sma-next-project/sam-react-prod` (Next.js) ## Components Migrated ### Dashboard Components (src/components/business/) 1. **Dashboard.tsx** - Main dashboard router with lazy loading 2. **CEODashboard.tsx** - CEO role dashboard 3. **ProductionManagerDashboard.tsx** - Production Manager dashboard 4. **WorkerDashboard.tsx** - Worker role dashboard 5. **SystemAdminDashboard.tsx** - System Admin dashboard 6. **SalesLeadDashboard.tsx** - Sales Lead dashboard ### Layout Components 1. **DashboardLayout.tsx** (src/layouts/) - Main layout with sidebar, header, and role switching ### Supporting Components 1. **Sidebar.tsx** (src/components/layout/) - Navigation sidebar component ### Hooks 1. **useUserRole.ts** - Hook for managing user roles 2. **useCurrentTime.ts** - Hook for current time display ### State Management (src/store/) 1. **menuStore.ts** - Zustand store for menu state 2. **themeStore.ts** - Zustand store for theme management 3. **demoStore.ts** - Demo data store ### UI Components 1. **calendar.tsx** - Calendar component 2. **sheet.tsx** - Sheet/drawer component 3. **chart-wrapper.tsx** - Chart wrapper component ## Dependencies Installed ```json { "zustand": "^latest", "recharts": "^latest", "react-day-picker": "^8", "date-fns": "^latest", "@radix-ui/react-dropdown-menu": "^latest", "@radix-ui/react-dialog": "^latest", "@radix-ui/react-checkbox": "^latest", "@radix-ui/react-switch": "^latest", "@radix-ui/react-popover": "^latest" } ``` ## Key Adaptations for Next.js ### 1. Router Changes - **Before**: `react-router-dom` with `useNavigate()` and `` - **After**: Next.js with `useRouter()`, `usePathname()` from `next/navigation` ### 2. Client Components - Added `'use client'` directive to: - `src/layouts/DashboardLayout.tsx` - `src/components/business/Dashboard.tsx` - All dashboard role components ### 3. Layout Pattern - **Before**: `` for nested routes - **After**: `{children}` prop pattern ### 4. Props Interface Added `DashboardLayoutProps` interface: ```typescript interface DashboardLayoutProps { children: React.ReactNode; } ``` ## Role-Based Dashboard System The system supports 5 user roles: 1. **CEO** - Full dashboard with business metrics 2. **ProductionManager** - Production-focused dashboard 3. **Worker** - Simple work performance dashboard 4. **SystemAdmin** - System management dashboard 5. **Sales** - Sales and leads dashboard Role switching is handled via: - localStorage user data - `useUserRole()` hook - Real-time updates via `roleChanged` event - Dynamic menu generation based on role ## Known Issues / Future Work ### ESLint Warnings Many components have ESLint warnings for: - Unused variables - Unused imports - TypeScript `any` types - Missing type definitions These need to be cleaned up but don't affect functionality. ### Missing Features - Some business components were copied but may need additional UI components - Route definitions in `app/` directory need to be created - API integration may need updates for Next.js API routes ## Next Steps 1. Create dashboard routes in `src/app/dashboard/` 2. Clean up ESLint errors and warnings 3. Test all role-based dashboards 4. Add missing UI components as needed 5. Update API calls for Next.js API routes 6. Add authentication guards 7. Test role switching functionality ## File Structure ``` src/ ├── app/ │ └── dashboard/ # (To be created) ├── components/ │ ├── business/ # All business components │ ├── layout/ │ │ └── Sidebar.tsx │ └── ui/ # UI primitives ├── hooks/ │ ├── useUserRole.ts │ └── useCurrentTime.ts ├── layouts/ │ └── DashboardLayout.tsx └── store/ ├── menuStore.ts ├── themeStore.ts └── demoStore.ts ``` ## Testing To test the migration: 1. Run `npm run dev` 2. Navigate to `/dashboard` 3. Test role switching via dropdown 4. Verify each dashboard loads correctly 5. Check responsive design (mobile/desktop)