import api from './axios'

// WhatsApp welcome template management (admin).
// Super admin manages the global default; franchisees manage their own single template.
export const getWhatsappTemplatesApi = () => api.get('admin/whatsapp-templates')
export const checkWhatsappTemplateNameApi = (label, id = null) =>
  api.get('admin/whatsapp-templates/check-name', { params: { label, ...(id ? { id } : {}) } })
// Abusive-language / profanity check on the body before submitting to Meta.
export const checkWhatsappTemplateMessageApi = (message) =>
  api.post('admin/whatsapp-templates/check-message', { message })
// AI-translate header/body/footer into a campaign language (variables preserved).
export const translateWhatsappTemplateContentApi = (payload) =>
  api.post('admin/whatsapp-templates/translate-content', payload)
export const createWhatsappTemplateApi = (payload) => api.post('admin/whatsapp-templates', payload)
export const updateWhatsappTemplateApi = (id, payload) => api.put(`admin/whatsapp-templates/${id}`, payload)
export const deleteWhatsappTemplateApi = (id) => api.delete(`admin/whatsapp-templates/${id}`)
export const setWhatsappTemplateDefaultApi = (id, isDefault) =>
  api.patch(`admin/whatsapp-templates/${id}/default`, { is_default: isDefault })
