import apiClient from '../../../shared/services/apiClient';

export type CookiePolicySettings = {
  analytics_enabled: boolean;
  marketing_enabled: boolean;
  preferences_enabled: boolean;
};

export type CookiePolicySettingsResponse = {
  status: string;
  data: CookiePolicySettings;
  updated_at?: string;
  updated_by?: string | null;
};

export type CookieIntegrationSettings = {
  ga_measurement_id?: string | null;
  fb_pixel_id?: string | null;
};

export type CookieIntegrationSettingsResponse = {
  status: string;
  data: CookieIntegrationSettings;
  updated_at?: string;
  updated_by?: string | null;
};

const adminPrivacyService = {
  getCookiePolicy: async (): Promise<CookiePolicySettingsResponse> => {
    const res = await apiClient.get<CookiePolicySettingsResponse>(
      '/admin/privacy/cookie-policy'
    );
    return res.data;
  },
  updateCookiePolicy: async (
    payload: CookiePolicySettings
  ): Promise<CookiePolicySettingsResponse> => {
    const res = await apiClient.put<CookiePolicySettingsResponse>(
      '/admin/privacy/cookie-policy',
      payload
    );
    return res.data;
  },
  getIntegrations: async (): Promise<CookieIntegrationSettingsResponse> => {
    const res = await apiClient.get<CookieIntegrationSettingsResponse>(
      '/admin/privacy/integrations'
    );
    return res.data;
  },
  updateIntegrations: async (
    payload: CookieIntegrationSettings
  ): Promise<CookieIntegrationSettingsResponse> => {
    const res = await apiClient.put<CookieIntegrationSettingsResponse>(
      '/admin/privacy/integrations',
      payload
    );
    return res.data;
  },
};

export default adminPrivacyService;

