import {
  EXECUTION_STATUS_ORDER,
  TASK_STATUS_ORDER,
  executionStatusFallbackNameMap,
  taskStatusFallbackNameMap
} from './shared';

export const mockExecutionStatusCounts: Record<Api.Project.ProjectExecutionStatusCode, number> =
  EXECUTION_STATUS_ORDER.reduce(
    (counts, statusCode) => ({
      ...counts,
      [statusCode]: 0
    }),
    {} as Record<Api.Project.ProjectExecutionStatusCode, number>
  );

export const mockTaskStatusColumns = TASK_STATUS_ORDER.map(statusCode => ({
  statusCode,
  statusName: taskStatusFallbackNameMap[statusCode],
  tasks: [] as Api.Project.ProjectTask[]
}));

export function createEmptyExecution(projectId: string): Api.Project.ProjectExecution {
  const now = new Date().toISOString();

  return {
    id: '',
    projectId,
    projectRequirementId: null,
    executionName: '',
    executionType: null,
    ownerId: '',
    ownerNickname: null,
    statusCode: 'pending',
    statusName: executionStatusFallbackNameMap.pending,
    terminal: false,
    allowEdit: true,
    availableActions: [],
    plannedStartDate: null,
    plannedEndDate: null,
    actualStartDate: null,
    actualEndDate: null,
    progressRate: 0,
    executionDesc: null,
    lastStatusReason: null,
    createTime: now,
    updateTime: now
  };
}
