import api from '../utils/request'

export interface Organization {
  id: number
  name: string
  description?: string | null
  sort_order: number
  created_at: string
  updated_at: string
}

export const getOrganizations = () => {
  return api.get<Organization[]>('/organizations/')
}

export const createOrganization = (data: {
  name: string
  description?: string
  sort_order?: number
}) => {
  return api.post<Organization>('/organizations/', data)
}

export const updateOrganization = (
  id: number,
  data: {
    name?: string
    description?: string
    sort_order?: number
    captcha_id: string
    captcha_code: string
  }
) => {
  return api.put<Organization>(`/organizations/${id}`, data)
}
