# Training Type Options Review ## Summary ปรับตัวเลือก `ประเภทการอบรม` ในโมดูล Training Records ให้เป็นรายการใหม่ 4 ตัวเลือกตามที่อนุมัติ และเพิ่มชั้น backward compatibility เพื่อรองรับข้อมูลเก่าในฐานข้อมูลโดยไม่ต้อง migrate enum เดิม ## Files Changed - `src/constants/thai-labels.ts` - `src/features/training-records/api/types.ts` - `src/features/training-records/constants/training-record-options.ts` - `src/features/training-records/schemas/training-record.ts` - `src/features/training-records/components/training-record-form.tsx` - `src/features/training-records/server/training-record-data.ts` ## Training Type Options Updated ตัวเลือกใหม่ที่แสดงใน UI: - `INTERNAL_TRAINING` -> `อบรมภายใน (Internal Training)` - `EXTERNAL_TRAINING` -> `อบรมภายนอก (Public Training)` - `ONLINE_COURSE` -> `e-Learning / Online Course` - `OJT` -> `On the Job Training (OJT)` ## Backward Compatibility Mapping ค่าจากฐานข้อมูลเดิมถูก map อย่างปลอดภัยดังนี้: - `internal` -> `INTERNAL_TRAINING` - `external` -> `EXTERNAL_TRAINING` - `online` -> `ONLINE_COURSE` - `onsite` -> `EXTERNAL_TRAINING` ค่าจาก UI ใหม่จะถูก map กลับก่อนบันทึกลง DB: - `INTERNAL_TRAINING` -> `internal` - `EXTERNAL_TRAINING` -> `external` - `ONLINE_COURSE` -> `online` - `OJT` -> `onsite` ## Validation Rules - ฟอร์ม Create/Edit อนุญาตเฉพาะ 4 ค่าใหม่เท่านั้น - ถ้าไม่ได้เลือกประเภทการอบรม จะแสดงข้อความ: - `กรุณาเลือกประเภทการอบรม` - เมื่อแก้ไข record เก่า ระบบจะ normalize ค่าเก่าเป็นค่าใหม่ก่อนแสดงในฟอร์ม ## UI Changes - dropdown ในหน้า Create Training Record แสดงเฉพาะ 4 ตัวเลือกใหม่ - dropdown ในหน้า Edit Training Record แสดงเฉพาะ 4 ตัวเลือกใหม่ - label ในหน้ารายละเอียด ตาราง และหน้า review ใช้ข้อความใหม่ - filter options ของประเภทการอบรมใช้ข้อความและค่าใหม่ ## Report/Filter Impact - ตาราง Training Records แสดง label ใหม่ - HRD Review page แสดง label ใหม่ - Report export ที่ใช้ `getTrainingTypeLabel(...)` แสดงข้อความใหม่อัตโนมัติ - filter ประเภทการอบรมสามารถส่งค่าชุดใหม่ได้ และ server จะ map กลับไป query ค่าเก่าใน DB ## Manual Test Checklist - Create form shows only 4 new training type options. - Edit form shows only 4 new training type options. - Training detail displays Thai/English label correctly. - HRD review displays training type correctly. - Training table displays training type correctly. - Reports display training type correctly. - Old INTERNAL value still displays safely. - Old EXTERNAL value still displays safely. - Old ONLINE value maps to e-Learning / Online Course. - Old ONSITE value maps safely. - Validation blocks empty training type. - Mobile dropdown works. ## Known Limitations - ฐานข้อมูลยังใช้ enum เก่าอยู่ (`online/onsite/internal/external`) เพื่อหลีกเลี่ยงการ migrate schema ในรอบนี้ - ค่าประวัติเดิม `onsite` ถูก map ไปแสดงเป็น `อบรมภายนอก (Public Training)` ตาม requirement นี้; ถ้าภายหลัง business ต้องการให้ `onsite` ไปที่ `OJT` จะต้องเปลี่ยน mapping rule เพิ่ม