import { apiClient } from './client'

export interface PinnedFlow {
  id: string
  tree_id: string
  tree_name: string
  tree_type: 'troubleshooting' | 'procedural' | 'maintenance'
  category_emoji?: string
  category_name?: string
  pinned_at: string
  display_order: number
}

export interface PinnedFlowsResponse {
  items: PinnedFlow[]
  count: number
}

export const pinnedFlowsApi = {
  list: async (): Promise<PinnedFlowsResponse> => {
    const { data } = await apiClient.get('/trees/pinned')
    return data
  },

  unpin: async (treeId: string): Promise<void> => {
    await apiClient.delete(`/trees/${treeId}/pin`)
  },

  pin: async (treeId: string): Promise<void> => {
    await apiClient.post(`/trees/${treeId}/pin`)
  },
}

export default pinnedFlowsApi
