import { ERoleCode, EMPTY_VALUE } from '../constant';
export var ETeacherType;
(function (ETeacherType) {
    // Giáo viên chủ nhiệm
    ETeacherType[ETeacherType["GVCN"] = 1] = "GVCN";
    // Giáo viên phụ
    ETeacherType[ETeacherType["GVP"] = 2] = "GVP";
    // Giáo viên bộ môn
    ETeacherType[ETeacherType["GVBM"] = 3] = "GVBM";
})(ETeacherType || (ETeacherType = {}));
export const getTeacherTypeName = (teacherType) => {
    switch (teacherType) {
        case ETeacherType.GVCN:
            return 'Giáo viên chủ nhiệm';
        case ETeacherType.GVP:
            return 'Giáo viên phụ';
        case ETeacherType.GVBM:
            return 'Giáo viên bộ môn';
        default:
            return '';
    }
};
export const transformTargetUser = (users, target) => users.map((user) => {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
    switch (target) {
        case ERoleCode.STUDENT: {
            const student = user;
            return {
                id: student.id,
                code: (_a = student.profile_student) === null || _a === void 0 ? void 0 : _a.user_code,
                name: student.full_name || EMPTY_VALUE,
                full_name: student.full_name || EMPTY_VALUE,
                location: ((_b = student.profile_student) === null || _b === void 0 ? void 0 : _b.user_code) || EMPTY_VALUE,
                email: student.email || EMPTY_VALUE,
                phone: student.phone_number || EMPTY_VALUE,
                classroom: ((_c = student.classroom_students) === null || _c === void 0 ? void 0 : _c.map((cs) => { var _a; return (_a = cs.classroom) === null || _a === void 0 ? void 0 : _a.name; }).join(', ')) || EMPTY_VALUE,
                educational_level: ((_f = (_e = (_d = student.profile_student) === null || _d === void 0 ? void 0 : _d.program_map_educational_level) === null || _e === void 0 ? void 0 : _e.educational_level) === null || _f === void 0 ? void 0 : _f.name) || EMPTY_VALUE,
                grade: ((_h = (_g = student.profile_student) === null || _g === void 0 ? void 0 : _g.grade) === null || _h === void 0 ? void 0 : _h.name) || EMPTY_VALUE,
                parents: (_j = student.relationshipUsersByStudentId) === null || _j === void 0 ? void 0 : _j.map((parent) => ({
                    id: parent.parent_id,
                    relationship_code: parent.relationship_code,
                    full_name: parent.user.full_name,
                })),
            };
        }
        case ERoleCode.TEACHER: {
            const teacher = user;
            const teacherType = Array.from(new Set((_m = (_l = (_k = teacher.profile_teacher) === null || _k === void 0 ? void 0 : _k.teacher_subject_assignments) === null || _l === void 0 ? void 0 : _l.flatMap((ut) => ut.classroom_teachers.map((ct) => getTeacherTypeName(ct.teacher_type)))) !== null && _m !== void 0 ? _m : [])).join(', ');
            return {
                id: teacher.id,
                code: (_o = teacher.profile_teacher) === null || _o === void 0 ? void 0 : _o.user_code,
                name: `${teacher.full_name} - ${((_p = teacher.profile_teacher) === null || _p === void 0 ? void 0 : _p.user_code) || EMPTY_VALUE}`,
                full_name: teacher.full_name || EMPTY_VALUE,
                email: teacher.email || EMPTY_VALUE,
                phone: teacher.phone_number || EMPTY_VALUE,
                location: [(_q = teacher.user_roles) === null || _q === void 0 ? void 0 : _q.map((ur) => { var _a; return (_a = ur.role) === null || _a === void 0 ? void 0 : _a.name; }).join(', '), teacherType].filter(Boolean).join(', ') ||
                    EMPTY_VALUE,
            };
        }
        case ERoleCode.STAFF: {
            const staff = user;
            const userCode = (_r = staff.profile_staff) === null || _r === void 0 ? void 0 : _r.user_code;
            return {
                id: staff.id,
                code: userCode || EMPTY_VALUE,
                name: `${staff.full_name} - ${userCode || EMPTY_VALUE}`,
                full_name: staff.full_name || EMPTY_VALUE,
                email: staff.email || EMPTY_VALUE,
                phone: staff.phone_number || EMPTY_VALUE,
                location: ((_s = staff.user_roles) === null || _s === void 0 ? void 0 : _s.map((ur) => { var _a; return (_a = ur.role) === null || _a === void 0 ? void 0 : _a.name; }).join(', ')) || EMPTY_VALUE,
            };
        }
        default:
            return {
                id: user.id,
                code: 'UNKNOWN',
                name: 'Unknown',
                full_name: '',
            };
    }
});
//# sourceMappingURL=tranform-target-user.js.map