9.5 KiB
9.5 KiB
Sprint 5 Review: Employee Import, Master Review, and Thai UI Localization
1. Summary
- Added the HRD-only Employee Import page at
/dashboard/import-employees. - Added Excel template download and
.xlsximport flow. - Added row validation, duplicate detection, and Thai import result summary.
- Imported employee runtime data into existing
usersandmembershipstables. - Added the HRD-only Master Review page at
/dashboard/master-review. - Added pending review handling for:
- companies
- departments
- positions
- Added approve/reject actions for pending master data.
- Converted visible TMS UI text in the implemented modules and shared dashboard surfaces to Thai.
- Centralized repeated Thai labels in
src/constants/thai-labels.ts.
2. Files changed
Employee Import
src/app/api/import-employees/route.tssrc/app/api/import-employees/template/route.tssrc/app/dashboard/import-employees/page.tsxsrc/app/dashboard/import-employees/loading.tsxsrc/app/dashboard/import-employees/error.tsxsrc/features/import-employees/api/types.tssrc/features/import-employees/api/service.tssrc/features/import-employees/api/queries.tssrc/features/import-employees/api/mutations.tssrc/features/import-employees/components/employee-import-page.tsx
Master Review
src/app/api/master-review/route.tssrc/app/dashboard/master-review/page.tsxsrc/app/dashboard/master-review/loading.tsxsrc/app/dashboard/master-review/error.tsxsrc/features/import-employees/components/master-review-page.tsx
Thai localization and shared UI
src/constants/thai-labels.tssrc/lib/api-client.tssrc/config/nav-config.tssrc/components/layout/app-sidebar.tsxsrc/components/layout/user-nav.tsxsrc/components/org-switcher.tsxsrc/components/search-input.tsxsrc/components/modal/alert-modal.tsxsrc/components/ui/table/data-table.tsxsrc/components/ui/table/data-table-pagination.tsxsrc/components/ui/table/data-table-toolbar.tsx
Training records and pending review localization
src/app/dashboard/training-records/loading.tsxsrc/app/dashboard/training-records/[trainingRecordId]/review/page.tsxsrc/app/dashboard/training-records/[trainingRecordId]/review/loading.tsxsrc/app/dashboard/training-records/[trainingRecordId]/review/error.tsxsrc/app/dashboard/pending-review/page.tsxsrc/app/dashboard/pending-review/loading.tsxsrc/app/dashboard/pending-review/error.tsxsrc/features/training-records/constants/training-record-options.tssrc/features/training-records/schemas/training-record.tssrc/features/training-records/components/pending-review-columns.tsxsrc/features/training-records/components/pending-review-table.tsxsrc/features/training-records/components/training-record-form.tsxsrc/features/training-records/components/training-record-review-form.tsxsrc/features/training-records/components/training-record-review-page.tsxsrc/features/training-records/components/training-record-certificate-manager.tsxsrc/features/training-records/components/training-record-tables/columns.tsxsrc/features/training-records/components/training-record-tables/index.tsxsrc/features/training-records/components/training-record-view-page.tsx
Courses, reports, overview, and training policy localization
src/app/dashboard/courses/page.tsxsrc/app/dashboard/courses/loading.tsxsrc/app/dashboard/courses/error.tsxsrc/app/dashboard/reports/page.tsxsrc/app/dashboard/reports/loading.tsxsrc/app/dashboard/reports/error.tsxsrc/app/dashboard/training-policy/page.tsxsrc/app/dashboard/training-policy/loading.tsxsrc/app/dashboard/training-policy/error.tsxsrc/app/dashboard/overview/layout.tsxsrc/app/dashboard/overview/error.tsxsrc/features/courses/components/course-form.tsxsrc/features/courses/components/course-tables/columns.tsxsrc/features/overview/server/overview-data.tssrc/features/overview/components/bar-graph.tsxsrc/features/overview/components/area-graph.tsxsrc/features/overview/components/pie-graph.tsxsrc/features/overview/components/recent-sales.tsxsrc/features/reports/components/report-table-card.tsxsrc/features/reports/components/reports-page-content.tsxsrc/features/reports/server/report-data.tssrc/features/training-policy/components/training-policy-form.tsxsrc/features/training-policy/components/training-policy-page.tsx
Dependency change
package.json- lockfile updated by
npm install xlsx
3. Database changes
- No schema migration was added in Sprint 5.
- No table names were changed.
- No column names were changed.
- Employee import reuses existing runtime tables:
usersmemberships
- Master review reuses existing flags and master tables:
organizations.pending_master_reviewdepartments.pending_master_reviewpositions.pending_master_review
4. Routes added
POST /api/import-employeesGET /api/import-employees/templateGET /api/master-reviewPATCH /api/master-review/dashboard/import-employees/dashboard/master-review
5. Thai localization changes
- Sidebar labels changed to Thai.
- Page titles and descriptions changed to Thai.
- Form labels and placeholders changed to Thai.
- Table headers and filter labels changed to Thai.
- Buttons and action labels changed to Thai.
- Status badges changed to Thai.
- Toast messages changed to Thai.
- Validation messages changed to Thai.
- Empty, loading, and error states changed to Thai.
- Dashboard overview cards and chart labels changed to Thai.
- CSV export headers changed to Thai.
- Import template headers changed to Thai.
6. Label mapping added
- Added central mapping file:
src/constants/thai-labels.ts - Reused helper functions:
getTrainingStatusLabel()getTrainingTypeLabel()getTrainingCategoryLabel()getRoleLabel()getActiveStatusLabel()
- Added Thai import template header constants and import status normalization.
7. Import template format
Required Thai headers:
รหัสพนักงานชื่อพนักงานอีเมลบริษัทแผนกตำแหน่งสถานะ
Supported file type:
.xlsx
Supported status values:
ใช้งานไม่ใช้งานactiveinactive
8. Validation rules
Employee import
- File is required.
- File must be
.xlsx. - Worksheet must exist.
- File must contain rows.
- Headers must match the Thai template headers.
- Required fields per row:
- employee code
- employee name
- company
- department
- position
- status
- Email is optional, but when present it must be valid.
- Duplicate employee codes in the same file are rejected.
- Duplicate emails in the same file are rejected.
- Status must normalize to active or inactive.
Training record review localization
- Approved hours must be at least
0.5. - Reject reason is required when rejecting.
- Thai validation messages are returned through the existing form flow.
9. Permission rules
- Employee Import page and APIs require HRD access through existing Auth.js session helpers.
- Master Review page and APIs require HRD access through existing Auth.js session helpers.
- Employee users cannot access
/dashboard/import-employees. - Employee users cannot access
/dashboard/master-review. - Imported records stay scoped to the active organization.
- Master review approve/reject updates are scoped to the active organization.
10. Manual test checklist
- HRD can open Employee Import page.
- Employee cannot open Employee Import page.
- HRD can download Thai Excel template.
- HRD can upload employee Excel.
- System validates required fields.
- System shows import result in Thai.
- New company/department/position becomes pending master review.
- HRD can open Master Review page.
- HRD can approve pending master data.
- HRD can reject pending master data.
- Sidebar menu is displayed in Thai.
- Training status badges are displayed in Thai.
- Training type labels are displayed in Thai.
- Form validation messages are displayed in Thai.
- Toast messages are displayed in Thai.
- Dashboard labels are displayed in Thai.
- Existing routes still work.
11. Known limitations
- There is no dedicated company master table in the current schema.
- Company review is therefore handled by comparing imported
users.company_namevalues against the active organization name. - Approving a pending company updates
organizations.namefor the active organization. - Rejecting a pending company normalizes affected imported users back to the current organization name.
- Imported users are created with generated password hashes so the runtime user row is valid, but credential onboarding or password reset flow is still a separate operational step.
- Employee import currently supports
.xlsxonly;.xlsand.csvare not included in this sprint.
12. Next recommended sprint
- Add audit log entries for employee import and master review actions.
- Add import history detail page from
import_jobs. - Add downloadable error report for failed import rows.
- Add a dedicated company master entity if company approval becomes a first-class workflow.
- Complete Thai localization for remaining non-TMS template/demo pages if those pages will stay in active use.
13. Migration command
- No new database migration is required for Sprint 5.
- If your environment has not installed the new Excel dependency yet, run:
npm install