import type { DevTask } from './dev-task'; import type { VersionPlan } from './version-plan'; import type { Priority } from './derive'; export type WorkItemEntityType = 'plan' | 'devTask' | 'testCase' | 'bug'; export interface WorkItem { entityType: WorkItemEntityType; entityId: string; title: string; status: string; isBlocked?: boolean; assigneeId: string; reviewerId?: string; versionId: string; versionName?: string; priority?: Priority; dueDate?: string; categoryLabel?: string; } export function planToWorkItem(plan: VersionPlan): WorkItem { return { entityType: 'plan', entityId: plan.id, title: plan.title, status: plan.status, assigneeId: plan.owner, versionId: plan.versionId, dueDate: plan.endTime.slice(0, 10), categoryLabel: plan.type === 'research' ? '调研' : plan.type === 'product' ? '产品方案' : 'UI设计', }; } export function devTaskToWorkItem(task: DevTask, versionId: string, categoryLabel?: string): WorkItem { return { entityType: 'devTask', entityId: task.id, title: task.title, status: task.status, isBlocked: task.isBlocked, assigneeId: task.assigneeId, reviewerId: task.reviewerId, versionId, priority: task.priority, dueDate: task.dueDate, categoryLabel, }; }