You are a Senior Full Stack Engineer.

Project:
Training Management System (TMS)

Current status:

- Sprint 4 is completed.
- Auth.js role mapping is completed.
- Sidebar displays menu by role.
- Employee Training Records module is completed.
- HRD Review Workflow is completed.

Current task:
Implement Sprint 5:
Employee Import, Master Review, and Thai UI Localization.

Important constraints:

- Do NOT change folder structure.
- Do NOT migrate ORM.
- Do NOT rename database tables.
- Do NOT rename database columns.
- Do NOT rename routes.
- Do NOT rename enum values.
- Use existing Drizzle ORM.
- Use existing Auth.js.
- Reuse existing UI components.
- Make minimal-impact changes only.

Part 1: Employee Import

Route:

- /dashboard/import-employees

Requirements:

1. HRD can upload Excel (.xlsx).
2. HRD can download import template.
3. Validate imported rows.
4. Import employee records.
5. Show import result summary.

Import fields:

- Employee Code
- Employee Name
- Email
- Company
- Department
- Position
- Status

Thai template headers:

- รหัสพนักงาน
- ชื่อพนักงาน
- อีเมล
- บริษัท
- แผนก
- ตำแหน่ง
- สถานะ

Part 2: Master Review

Route:

- /dashboard/master-review

Requirements:

1. Show pending companies.
2. Show pending departments.
3. Show pending positions.
4. HRD can approve or reject pending master records.
5. Approved records become active master data.

Thai labels:

- รอตรวจสอบข้อมูลหลัก
- บริษัท
- แผนก
- ตำแหน่ง
- อนุมัติ
- ไม่อนุมัติ

Part 3: Thai UI Localization

Convert all visible UI text to Thai across the existing TMS system.

Scope:

1. Sidebar menu labels
2. Page titles
3. Form labels
4. Table headers
5. Buttons
6. Status badges
7. Toast messages
8. Validation messages
9. Empty states
10. Loading states
11. Error states
12. Dashboard cards
13. Export headers
14. Import template headers

Important:
Keep internal values in English.

Examples:

- PENDING_REVIEW should display as "รอตรวจสอบ"
- APPROVED should display as "อนุมัติแล้ว"
- REJECTED should display as "ไม่อนุมัติ"
- ONLINE should display as "ออนไลน์"
- ONSITE should display as "อบรม ณ สถานที่"
- INTERNAL should display as "ภายในองค์กร"
- EXTERNAL should display as "ภายนอกองค์กร"
- K should display as "Knowledge (ความรู้)"
- S should display as "Skill (ทักษะ)"
- A should display as "Attitude (ทัศนคติ)"

Recommended approach:

1. Create or update a central label mapping file, for example:
   src/constants/thai-labels.ts
2. Reuse label helper functions across modules:
   - getTrainingStatusLabel()
   - getTrainingTypeLabel()
   - getTrainingCategoryLabel()
   - getRoleLabel()
3. Avoid hardcoding repeated Thai labels in multiple files.

Part 4: Output Review File

Create:

docs/sprint-5-employee-import-master-review-thai-localization.md

The review file must include:

1. Summary
2. Files changed
3. Database changes
4. Routes added
5. Thai localization changes
6. Label mapping added
7. Import template format
8. Validation rules
9. Permission rules
10. Manual test checklist
11. Known limitations
12. Next recommended sprint

Manual test checklist must include:

- 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.

Return:

- Complete code changes with file paths.
- Content of docs/sprint-5-employee-import-master-review-thai-localization.md.
- Any migration command if required.
