update
This commit is contained in:
84
Frontend/src/services/api/privacyService.ts
Normal file
84
Frontend/src/services/api/privacyService.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import apiClient from './apiClient';
|
||||
|
||||
export type CookieCategoryPreferences = {
|
||||
necessary: boolean;
|
||||
analytics: boolean;
|
||||
marketing: boolean;
|
||||
preferences: boolean;
|
||||
};
|
||||
|
||||
export type CookieConsent = {
|
||||
version: number;
|
||||
updated_at: string;
|
||||
has_decided: boolean;
|
||||
categories: CookieCategoryPreferences;
|
||||
};
|
||||
|
||||
export type CookieConsentResponse = {
|
||||
status: string;
|
||||
data: CookieConsent;
|
||||
};
|
||||
|
||||
export type UpdateCookieConsentRequest = {
|
||||
analytics?: boolean;
|
||||
marketing?: boolean;
|
||||
preferences?: boolean;
|
||||
};
|
||||
|
||||
export type PublicPrivacyConfig = {
|
||||
policy: {
|
||||
analytics_enabled: boolean;
|
||||
marketing_enabled: boolean;
|
||||
preferences_enabled: boolean;
|
||||
};
|
||||
integrations: {
|
||||
ga_measurement_id?: string | null;
|
||||
fb_pixel_id?: string | null;
|
||||
};
|
||||
};
|
||||
|
||||
export type PublicPrivacyConfigResponse = {
|
||||
status: string;
|
||||
data: PublicPrivacyConfig;
|
||||
};
|
||||
|
||||
const privacyService = {
|
||||
/**
|
||||
* Fetch current cookie consent from the backend.
|
||||
*/
|
||||
getCookieConsent: async (): Promise<CookieConsent> => {
|
||||
const response = await apiClient.get<CookieConsentResponse>(
|
||||
'/privacy/cookie-consent'
|
||||
);
|
||||
return response.data.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Fetch public privacy configuration:
|
||||
* - global policy flags
|
||||
* - integration IDs (e.g. GA4, Meta Pixel)
|
||||
*/
|
||||
getPublicConfig: async (): Promise<PublicPrivacyConfig> => {
|
||||
const response = await apiClient.get<PublicPrivacyConfigResponse>(
|
||||
'/privacy/config'
|
||||
);
|
||||
return response.data.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Update cookie consent preferences on the backend.
|
||||
*/
|
||||
updateCookieConsent: async (
|
||||
payload: UpdateCookieConsentRequest
|
||||
): Promise<CookieConsent> => {
|
||||
const response = await apiClient.post<CookieConsentResponse>(
|
||||
'/privacy/cookie-consent',
|
||||
payload
|
||||
);
|
||||
return response.data.data;
|
||||
},
|
||||
};
|
||||
|
||||
export default privacyService;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user