import { api } from './api';
import type { ExternalLinks, ServiceModeStatus } from '../types/config.types';

interface ApiResponse<T> {
  success: boolean;
  data: T;
}

export interface PdfSettings {
  pdf_header: string;
  pdf_footer: string;
  pdf_logo: string;
  pdf_org_name: string;
  app_logo?: string;
}

export const configApi = {
  getExternalLinks(): Promise<ExternalLinks> {
    return api
      .get<ApiResponse<ExternalLinks>>('/api/config/external-links')
      .then((r) => r.data.data);
  },
  getServiceMode(): Promise<ServiceModeStatus> {
    return api
      .get<ApiResponse<ServiceModeStatus>>('/api/config/service-mode')
      .then((r) => r.data.data);
  },
  getPdfSettings(): Promise<PdfSettings> {
    return api
      .get<ApiResponse<PdfSettings>>('/api/config/pdf-settings')
      .then((r) => r.data.data);
  },
};
