import { API_BASE_URL } from '../config/api'; // Types for About Us data export interface AboutStat { number: string; label: string; order: number; } export interface AboutSocialLink { platform: string; url: string; icon: string; aria_label: string; order: number; } export interface AboutBanner { id: number; title: string; subtitle: string; description: string; badge_text: string; badge_icon: string; cta_text: string; cta_link: string; cta_icon: string; image_url: string | null; is_active: boolean; stats: AboutStat[]; social_links: AboutSocialLink[]; created_at: string; updated_at: string; } export interface AboutFeature { title: string; description: string; icon: string; order: number; } export interface AboutService { id: number; title: string; subtitle: string; description: string; badge_text: string; badge_icon: string; image_url: string | null; cta_text: string; cta_link: string; is_active: boolean; features: AboutFeature[]; created_at: string; updated_at: string; } export interface AboutProcessStep { step_number: string; title: string; description: string; order: number; } export interface AboutProcess { id: number; title: string; subtitle: string; description: string; badge_text: string; badge_icon: string; image_url: string | null; cta_text: string; cta_link: string; is_active: boolean; steps: AboutProcessStep[]; created_at: string; updated_at: string; } export interface AboutMilestone { year: string; title: string; description: string; order: number; } export interface AboutJourney { id: number; title: string; subtitle: string; description: string; badge_text: string; badge_icon: string; image_url: string | null; cta_text: string; cta_link: string; is_active: boolean; milestones: AboutMilestone[]; created_at: string; updated_at: string; } export interface AboutPageData { banner: AboutBanner; service: AboutService; process: AboutProcess; journey: AboutJourney; } class AboutServiceAPI { private baseUrl = `${API_BASE_URL}/api/about`; /** * Get all about page data in one request */ async getAboutPageData(): Promise { try { const response = await fetch(`${this.baseUrl}/page/`, { 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; } } /** * Get all about 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 about 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; } } /** * Get all about services */ async getServices(): Promise { try { const response = await fetch(`${this.baseUrl}/service/`, { 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 about service by ID */ async getService(id: number): Promise { try { const response = await fetch(`${this.baseUrl}/service/${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; } } /** * Get all about processes */ async getProcesses(): Promise { try { const response = await fetch(`${this.baseUrl}/process/`, { 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 about process by ID */ async getProcess(id: number): Promise { try { const response = await fetch(`${this.baseUrl}/process/${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; } } /** * Get all about journeys */ async getJourneys(): Promise { try { const response = await fetch(`${this.baseUrl}/journey/`, { 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 about journey by ID */ async getJourney(id: number): Promise { try { const response = await fetch(`${this.baseUrl}/journey/${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 a singleton instance export const aboutService = new AboutServiceAPI(); export default aboutService;