import api from './axios'

// WhatsApp message flow.
// Super admin creates/edits/orders the messages; franchisees can only translate.
export const getWhatsappMessagesApi = () => api.get('admin/whatsapp-messages')
export const createWhatsappMessageApi = (payload) => api.post('admin/whatsapp-messages', payload)
export const updateWhatsappMessageApi = (id, payload) => api.put(`admin/whatsapp-messages/${id}`, payload)
export const deleteWhatsappMessageApi = (id) => api.delete(`admin/whatsapp-messages/${id}`)
export const reorderWhatsappMessagesApi = (order) => api.post('admin/whatsapp-messages/reorder', { order })
export const adoptGlobalWhatsappMessagesApi = () => api.post('admin/whatsapp-messages/adopt-global')
export const translateWhatsappMessageApi = (id, payload) =>
  api.post(`admin/whatsapp-messages/${id}/translate`, payload)

// Per-language translation (franchisee): fetch + bulk save.
export const getWhatsappMessageTranslationsApi = (languageCode) =>
  api.get(`admin/whatsapp-messages/translations/${languageCode}`)
// AI translate uses the shared translate endpoint (type + ids), same as programs/activities.
export const translateWhatsappMessagesApi = (payload) => api.post('admin/translate', payload)
export const getWhatsappMessageApi = (id) => api.get(`admin/whatsapp-messages/${id}`)

// Question-type support (custom | age | program).
export const getWhatsappAgeOptionsApi = () => api.get('admin/whatsapp-messages/age-options')
export const getWhatsappProgramOptionsApi = () => api.get('admin/whatsapp-messages/program-options')
export const getWhatsappProgramsForAgeApi = (age) =>
  api.get('admin/whatsapp-messages/programs-for-age', { params: { age } })
export const saveWhatsappMessageTranslationsApi = (payload) =>
  api.post('admin/whatsapp-messages/translations', payload)
