import api from './client'

export interface ImportValidation {
  id: string
  status: 'pending' | 'running' | 'completed' | 'failed'
  summary: {
    total_rows: number
    rows_with_cad: number
    rows_without_cad: number
    unresolvable_materials: Array<{ row_name: string; material: string }>
  } | null
  created_at: string
  completed_at: string | null
}

export async function getImportValidation(id: string): Promise<ImportValidation> {
  const res = await api.get(`/imports/validation/${id}`)
  return res.data
}

export async function addMaterialAliasFromValidation(validationId: string, partName: string, materialName: string): Promise<void> {
  await api.post(`/imports/validation/${validationId}/add-alias`, { part_name: partName, material_name: materialName })
}
