import http from '@/http';

/** Soutien de l'association tel que le renvoie `GET /soutiens` (spec L6, L11). */
export interface Soutien {
  souId: number;
  souNom: string;
  souUrl: string | null;
  souDescription: string | null;
  souPiedDePage: boolean;
  /** URL réelle du logo, null quand aucun logo n'est chargé. */
  logoUrl: string | null;
}

/** Soutiens actifs, triés ; `piedDePage` restreint à ceux cochés pour le pied de page. Vide si l'API échoue. */
export async function getSoutiens(piedDePage = false): Promise<Soutien[]> {
  try {
    const response = await http.get(piedDePage ? '/soutiens?piedDePage=1' : '/soutiens');
    return response.data ?? [];
  } catch {
    return [];
  }
}
