Files
prop-ai-hr/mobile-uni/src/services/candidate-view.ts
T

131 lines
3.8 KiB
TypeScript

import type { CandidateMaterial, InterviewRecord } from '@/types/api';
export const candidateRoutes = {
index: '/pages/candidate/index/index',
interview: '/pages/candidate/interview/index',
materials: '/pages/candidate/materials/index',
progress: '/pages/candidate/progress/index',
study: '/pages/candidate/study/index'
} as const;
export type CandidateStage = 'interview' | 'materials' | 'review' | 'complete';
export interface CandidateFlow {
stage: CandidateStage;
badge: string;
title: string;
desc: string;
progress: number;
progressText: string;
notice: string;
cta: string;
route: string;
}
export interface CandidateStep {
index: number;
title: string;
desc: string;
status: 'complete' | 'current' | 'pending';
}
export const buildCandidateFlow = (
records: InterviewRecord[],
materials: CandidateMaterial[]
): CandidateFlow => {
if (!records.length) {
return {
stage: 'interview',
badge: '待面试',
title: '完成结构化面试',
desc: '按岗位题目完成回答,提交后生成正式面试记录。',
progress: 0,
progressText: '0/2',
notice: '待完成结构化面试',
cta: '开始面试',
route: candidateRoutes.interview
};
}
const materialStatus = materials[0]?.status || '';
if (!materials.length || materialStatus === '已驳回') {
const rejected = materialStatus === '已驳回';
return {
stage: 'materials',
badge: rejected ? '资料被驳回' : '待补资料',
title: rejected ? '重新提交资料' : '上传补充资料',
desc: rejected ? '请按审核结果补充或替换资料。' : '上传简历、证书或相关图片,供 HR 审核。',
progress: 50,
progressText: '1/2',
notice: rejected ? '资料被驳回,请重新上传' : '面试已完成,请上传补充资料',
cta: rejected ? '重新上传' : '上传资料',
route: candidateRoutes.materials
};
}
if (materialStatus === '已通过') {
return {
stage: 'complete',
badge: '资料已通过',
title: '等待后续通知',
desc: '面试和补充资料已完成,请留意 HR 后续通知。',
progress: 100,
progressText: '2/2',
notice: '资料已通过,等待后续通知',
cta: '查看进度',
route: candidateRoutes.progress
};
}
return {
stage: 'review',
badge: '审核中',
title: '资料审核中',
desc: '资料已提交,审核结果会同步到进度页。',
progress: 75,
progressText: '1/2',
notice: '资料已提交,等待 HR 审核',
cta: '查看进度',
route: candidateRoutes.progress
};
};
export const buildCandidateSteps = (flow: CandidateFlow): CandidateStep[] => {
const interviewComplete = flow.stage !== 'interview';
const materialsComplete = flow.stage === 'complete';
const materialsCurrent = flow.stage === 'materials' || flow.stage === 'review';
return [
{
index: 1,
title: '完成面试',
desc: '按岗位题目作答并生成面试记录',
status: interviewComplete ? 'complete' : 'current'
},
{
index: 2,
title: '提交资料',
desc: '上传简历、证书或相关图片',
status: materialsComplete ? 'complete' : materialsCurrent ? 'current' : 'pending'
},
{
index: 3,
title: '等待通知',
desc: 'HR 审核后同步展示最新状态',
status: materialsComplete ? 'current' : 'pending'
}
];
};
export const formatCandidateFileSize = (size: number) => {
if (!size) return '0KB';
if (size < 1024 * 1024) return `${Math.ceil(size / 1024)}KB`;
return `${(size / 1024 / 1024).toFixed(1)}MB`;
};
export const materialStatusTone = (status: string) => {
if (status === '已通过') return 'passed';
if (status === '已驳回') return 'rejected';
return 'pending';
};