Files
alla-tms/docs/management-change-add-employee-directory-menu-review.md
2026-07-16 09:53:14 +07:00

107 lines
4.3 KiB
Markdown

# Summary
Added a new HRD-only submenu `รายชื่อพนักงานทั้งหมด` under `ข้อมูลหลัก` while keeping the existing `พนักงาน` menu and route unchanged. The new page provides a searchable employee directory and a protected employee detail page with training-hour and K/S/A summaries.
# Files Changed
- `src/config/nav-config.ts`
- `src/hooks/use-breadcrumbs.tsx`
- `src/app/dashboard/employee-directory/page.tsx`
- `src/app/dashboard/employee-directory/[id]/page.tsx`
- `src/features/employee-directory/components/employee-directory-action-menu.tsx`
- `src/features/employee-directory/components/employee-directory-columns.tsx`
- `src/features/employee-directory/components/employee-directory-table.tsx`
- `src/features/employee-directory/components/employee-directory-listing.tsx`
- `src/features/employee-directory/components/employee-directory-detail-page.tsx`
- `src/features/employee-directory/server/employee-directory-data.ts`
- `docs/management-change-add-employee-directory-menu-review.md`
# Sidebar Changes
- Kept the existing `พนักงาน` submenu under `ข้อมูลหลัก`
- Added a new submenu:
- `รายชื่อพนักงานทั้งหมด`
- route: `/dashboard/employee-directory`
- Visibility is limited to HRD/Admin via existing role-based navigation rules
# New Routes
- `/dashboard/employee-directory`
- `/dashboard/employee-directory/[id]`
# Existing Employee Menu Kept
- The existing `พนักงาน` menu remains unchanged
- Existing route `/dashboard/users` remains unchanged
- Existing users page behavior is untouched
# Employee Directory Page
- Reuses the existing users data source for minimal-impact implementation
- Search supports the existing backend search across:
- employee code
- employee name
- email
- department
- position
- Table columns:
- รหัสพนักงาน
- ชื่อพนักงาน
- ฝ่าย
- ตำแหน่ง
- Action
- Action uses a compact three-dot menu with `ดูข้อมูลพนักงาน`
# Employee Detail Page
- Protected server-rendered detail page for HRD/Admin only
- Sections included:
1. ข้อมูลทั่วไปพนักงาน
2. ข้อมูลชั่วโมงอบรม
3. K / S / A Summary
4. รายการอบรม
- Training summary uses current-year targets and current-year approved/pending/rejected hours
- Training records list links back to the existing training record detail pages
# Permission Rules
- HRD/Admin:
- can see the new menu
- can access the directory list
- can open employee detail pages
- Employee:
- does not see the menu
- cannot access the routes directly because the pages use `requireHRDDashboardAccess()`
# Responsive Notes
- The directory table uses the existing scrollable table container
- The action column is compact and pinned-friendly
- Detail sections stack into single-column layouts on smaller screens
- Training records in the detail page use horizontal scrolling inside the section instead of expanding page width
# Manual Test Checklist
- [ ] Existing `พนักงาน` menu remains
- [ ] New `รายชื่อพนักงานทั้งหมด` menu appears under `ข้อมูลหลัก`
- [ ] HRD/Admin can open employee directory
- [ ] Employee cannot see employee directory menu
- [ ] Employee cannot access employee directory by URL
- [ ] Employee directory table shows employee code
- [ ] Employee directory table shows employee name
- [ ] Employee directory table shows department/faction
- [ ] Employee directory table shows position
- [ ] Action opens employee detail
- [ ] Detail page shows general employee data
- [ ] Detail page shows training hour summary
- [ ] Detail page shows K/S/A summary
- [ ] Detail page shows training records
- [ ] Mobile layout works
- [ ] Existing `พนักงาน` page still works
# Known Limitations
- The current schema does not have a separate dedicated `ฝ่าย` field, so this page displays the available department data in that slot.
- The summary cards use the current year for target and hour progress calculations.
- Certificate status in the training-record list is shown as file count with a link to the existing training record detail page.