import { api } from '../api'

export interface PipelineStage {
  name: string
  nameAr?: string
  order: number
}

export interface Pipeline {
  id: string
  name: string
  nameAr?: string
  structure: string
  stages: PipelineStage[]
  isActive: boolean
}

export const pipelinesAPI = {
  getAll: async (structure?: string): Promise<Pipeline[]> => {
    const params = new URLSearchParams()
    if (structure) params.append('structure', structure)
    const response = await api.get(`/crm/pipelines?${params.toString()}`)
    return response.data.data
  },

  getById: async (id: string): Promise<Pipeline> => {
    const response = await api.get(`/crm/pipelines/${id}`)
    return response.data.data
  }
}
