import http from '@/http';

/** Alertes sur les favoris et « recevoir les mails » (newsletter), spec L186. */
export interface NotificationPreferences {
  alertesActivees: boolean;
  newsletter: boolean;
}

export async function getNotificationPreferences(): Promise<NotificationPreferences> {
  const response = await http.get('/notification-preferences');
  return response.data;
}

/** N'envoie que les préférences modifiées ; l'API renvoie l'état complet. */
export async function updatePreferences(patch: Partial<NotificationPreferences>): Promise<NotificationPreferences> {
  const response = await http.put('/notification-preferences', patch);
  return response.data;
}

export async function updateNotificationPreferences(alertesActivees: boolean): Promise<NotificationPreferences> {
  return updatePreferences({ alertesActivees });
}
