Files
jiaowu-test/src/constants/statusMap.js

283 lines
5.0 KiB
JavaScript
Raw Normal View History

// Status mapping constants for converting between frontend and backend values
// Application status mapping
export const APPLICATION_STATUS_MAP = {
// Backend -> Frontend
toFrontend: {
'SCHEDULED': 'applied',
'COMPLETED': 'interview_success',
'CANCELLED': 'interview_failed',
'NO_SHOW': 'not_applied',
},
// Frontend -> Backend
toBackend: {
'not_applied': null,
'applied': 'SCHEDULED',
'interview_success': 'COMPLETED',
'accepted': 'COMPLETED',
'interview_failed': 'CANCELLED',
},
};
// Enrollment status mapping
export const ENROLLMENT_STATUS_MAP = {
// Backend values
NOT_STARTED: {
text: '未开始',
color: '#999999',
progress: 0,
},
IN_PROGRESS: {
text: '学习中',
color: '#3b82f6',
progress: 50,
},
COMPLETED: {
text: '已完成',
color: '#10b981',
progress: 100,
},
};
// Interview status mapping
export const INTERVIEW_STATUS_MAP = {
// Backend values
SCHEDULED: {
text: '待面试',
color: '#f59e0b',
icon: 'clock',
},
COMPLETED: {
text: '已完成',
color: '#10b981',
icon: 'check',
},
CANCELLED: {
text: '已取消',
color: '#ef4444',
icon: 'close',
},
NO_SHOW: {
text: '未到场',
color: '#6b7280',
icon: 'warning',
},
};
// Interview result mapping
export const INTERVIEW_RESULT_MAP = {
PASS: {
text: '通过',
color: '#10b981',
applicationStatus: 'interview_success',
},
FAIL: {
text: '未通过',
color: '#ef4444',
applicationStatus: 'interview_failed',
},
PENDING: {
text: '待定',
color: '#f59e0b',
applicationStatus: 'applied',
},
OFFER: {
text: '已发Offer',
color: '#10b981',
applicationStatus: 'accepted',
},
};
// Job type mapping
export const JOB_TYPE_MAP = {
// Backend -> Frontend display
FULLTIME: {
text: '全职',
value: 'fulltime',
color: '#3b82f6',
},
PARTTIME: {
text: '兼职',
value: 'parttime',
color: '#8b5cf6',
},
INTERNSHIP: {
text: '实习',
value: 'internship',
color: '#ec4899',
},
CONTRACT: {
text: '合同制',
value: 'contract',
color: '#f59e0b',
},
REMOTE: {
text: '远程',
value: 'remote',
color: '#10b981',
},
};
// Job level mapping
export const JOB_LEVEL_MAP = {
JUNIOR: {
text: '初级',
minExperience: 0,
maxExperience: 2,
},
MID: {
text: '中级',
minExperience: 2,
maxExperience: 5,
},
SENIOR: {
text: '高级',
minExperience: 5,
maxExperience: 10,
},
LEAD: {
text: '资深',
minExperience: 8,
maxExperience: 15,
},
MANAGER: {
text: '管理',
minExperience: 5,
maxExperience: null,
},
};
// Course category mapping
export const COURSE_CATEGORY_MAP = {
GENERAL: {
text: '通识课程',
color: '#6b7280',
icon: 'book',
},
PROFESSIONAL: {
text: '专业课程',
color: '#3b82f6',
icon: 'desktop',
},
PRACTICAL: {
text: '实践课程',
color: '#10b981',
icon: 'tool',
},
COMPREHENSIVE: {
text: '综合课程',
color: '#8b5cf6',
icon: 'layers',
},
};
// Course type mapping
export const COURSE_TYPE_MAP = {
LIVE: {
text: '直播课',
color: '#ef4444',
icon: 'video',
},
RECORDED: {
text: '录播课',
color: '#3b82f6',
icon: 'play',
},
HYBRID: {
text: '混合式',
color: '#8b5cf6',
icon: 'mix',
},
OFFLINE: {
text: '线下课',
color: '#10b981',
icon: 'location',
},
};
// Gender mapping
export const GENDER_MAP = {
MALE: '男',
FEMALE: '女',
};
// Company scale mapping
export const COMPANY_SCALE_MAP = {
SMALL: {
text: '50人以下',
min: 0,
max: 50,
},
MEDIUM: {
text: '50-200人',
min: 50,
max: 200,
},
LARGE: {
text: '200-1000人',
min: 200,
max: 1000,
},
ENTERPRISE: {
text: '1000人以上',
min: 1000,
max: null,
},
};
// Interview type mapping
export const INTERVIEW_TYPE_MAP = {
PHONE: {
text: '电话面试',
icon: 'phone',
},
VIDEO: {
text: '视频面试',
icon: 'video',
},
ONSITE: {
text: '现场面试',
icon: 'location',
},
TECHNICAL: {
text: '技术面试',
icon: 'code',
},
HR: {
text: 'HR面试',
icon: 'user',
},
};
// Helper functions
export const getStatusText = (status, map) => {
return map[status]?.text || status;
};
export const getStatusColor = (status, map) => {
return map[status]?.color || '#6b7280';
};
export const mapApplicationStatus = (backendStatus, result = null) => {
if (result && INTERVIEW_RESULT_MAP[result]) {
return INTERVIEW_RESULT_MAP[result].applicationStatus;
}
return APPLICATION_STATUS_MAP.toFrontend[backendStatus] || 'not_applied';
};
export default {
APPLICATION_STATUS_MAP,
ENROLLMENT_STATUS_MAP,
INTERVIEW_STATUS_MAP,
INTERVIEW_RESULT_MAP,
JOB_TYPE_MAP,
JOB_LEVEL_MAP,
COURSE_CATEGORY_MAP,
COURSE_TYPE_MAP,
GENDER_MAP,
COMPANY_SCALE_MAP,
INTERVIEW_TYPE_MAP,
getStatusText,
getStatusColor,
mapApplicationStatus,
};