import { processes } from '@/data'

export interface ProcessPurposePracticeItem {
  id: string
  name: string
  purpose: string
}

function getPracticePurpose(id: string, purpose: string): string {
  if (id === 'P1.1') {
    return purpose.replace(/^项目章程/, '')
  }

  return purpose
}

export const processPurposePracticeItems: ProcessPurposePracticeItem[] =
  processes
    .slice()
    .sort((a, b) => a.order - b.order)
    .map((process) => ({
      id: process.id,
      name: process.name,
      purpose: getPracticePurpose(process.id, process.purpose || ''),
    }))
