import { API_BASE_URL } from '../config/api'; // Types for Home Banner data export interface HomeBanner { id: number; icon: string; badge: string; heading: string; highlight: string; subheading: string; description: string; button_text: string; button_url: string; display_order: number; is_active: boolean; created_at: string; updated_at: string; } class HomeServiceAPI { private baseUrl = `${API_BASE_URL}/api/home`; /** * Get all home banners */ async getBanners(): Promise { try { const response = await fetch(`${this.baseUrl}/banner/`, { method: 'GET', headers: { 'Content-Type': 'application/json', }, }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); return data.results || data; } catch (error) { throw error; } } /** * Get a specific home banner by ID */ async getBanner(id: number): Promise { try { const response = await fetch(`${this.baseUrl}/banner/${id}/`, { method: 'GET', headers: { 'Content-Type': 'application/json', }, }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); return data; } catch (error) { throw error; } } } export const homeService = new HomeServiceAPI();