import { BE_SETTINGS_SMTP_URL } from '@/utils/Url';
import { fetchWithAuth } from '@/utils/fetchWithAuth';

export const PENDING = 'pending';
export const SUBSCRIBED = 'subscribed';
export const ARCHIVED = 'archived';

export const fetchSmtpSettings = (csrfToken, establishment_id = null) => {
  let url = `${BE_SETTINGS_SMTP_URL}/`;
  if (establishment_id) {
    url += `?establishment_id=${establishment_id}`;
  }
  return fetchWithAuth(url, {
    headers: { 'X-CSRFToken': csrfToken },
  });
};

export const editSmtpSettings = (data, csrfToken) => {
  return fetchWithAuth(`${BE_SETTINGS_SMTP_URL}/`, {
    method: 'POST',
    headers: { 'X-CSRFToken': csrfToken },
    body: JSON.stringify(data),
  });
};
