mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
feat: add admin legal pages api client and display mode types
This commit is contained in:
152
src/api/adminLegalPages.ts
Normal file
152
src/api/adminLegalPages.ts
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
import apiClient from './client';
|
||||||
|
|
||||||
|
export type LegalDisplayMode = 'bot' | 'web' | 'both';
|
||||||
|
|
||||||
|
export interface LegalDocumentItem {
|
||||||
|
language: string;
|
||||||
|
content: string;
|
||||||
|
is_enabled: boolean;
|
||||||
|
updated_at: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LegalDocumentResponse {
|
||||||
|
display_mode: LegalDisplayMode;
|
||||||
|
display_mode_env_locked: boolean;
|
||||||
|
items: LegalDocumentItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LegalDocumentUpdateRequest {
|
||||||
|
display_mode?: LegalDisplayMode;
|
||||||
|
items?: Array<{ language: string; content: string; is_enabled: boolean }>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RulesItem {
|
||||||
|
language: string;
|
||||||
|
content: string;
|
||||||
|
updated_at: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RulesResponse {
|
||||||
|
display_mode: LegalDisplayMode;
|
||||||
|
display_mode_env_locked: boolean;
|
||||||
|
items: RulesItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RulesUpdateRequest {
|
||||||
|
display_mode?: LegalDisplayMode;
|
||||||
|
items?: Array<{ language: string; content: string }>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FaqSettingItem {
|
||||||
|
language: string;
|
||||||
|
is_enabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FaqPageItem {
|
||||||
|
id: number;
|
||||||
|
language: string;
|
||||||
|
title: string;
|
||||||
|
content: string;
|
||||||
|
display_order: number;
|
||||||
|
is_active: boolean;
|
||||||
|
updated_at: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FaqResponse {
|
||||||
|
display_mode: LegalDisplayMode;
|
||||||
|
display_mode_env_locked: boolean;
|
||||||
|
settings: FaqSettingItem[];
|
||||||
|
pages: FaqPageItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FaqUpdateRequest {
|
||||||
|
display_mode?: LegalDisplayMode;
|
||||||
|
settings?: FaqSettingItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FaqPageCreateRequest {
|
||||||
|
language: string;
|
||||||
|
title: string;
|
||||||
|
content: string;
|
||||||
|
display_order?: number;
|
||||||
|
is_active?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FaqPageUpdateRequest {
|
||||||
|
title?: string;
|
||||||
|
content?: string;
|
||||||
|
display_order?: number;
|
||||||
|
is_active?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const adminLegalPagesApi = {
|
||||||
|
getPrivacyPolicy: async (): Promise<LegalDocumentResponse> => {
|
||||||
|
const response = await apiClient.get<LegalDocumentResponse>(
|
||||||
|
'/cabinet/admin/legal-pages/privacy-policy',
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
updatePrivacyPolicy: async (data: LegalDocumentUpdateRequest): Promise<LegalDocumentResponse> => {
|
||||||
|
const response = await apiClient.put<LegalDocumentResponse>(
|
||||||
|
'/cabinet/admin/legal-pages/privacy-policy',
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
getPublicOffer: async (): Promise<LegalDocumentResponse> => {
|
||||||
|
const response = await apiClient.get<LegalDocumentResponse>(
|
||||||
|
'/cabinet/admin/legal-pages/public-offer',
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
updatePublicOffer: async (data: LegalDocumentUpdateRequest): Promise<LegalDocumentResponse> => {
|
||||||
|
const response = await apiClient.put<LegalDocumentResponse>(
|
||||||
|
'/cabinet/admin/legal-pages/public-offer',
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
getRules: async (): Promise<RulesResponse> => {
|
||||||
|
const response = await apiClient.get<RulesResponse>('/cabinet/admin/legal-pages/rules');
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
updateRules: async (data: RulesUpdateRequest): Promise<RulesResponse> => {
|
||||||
|
const response = await apiClient.put<RulesResponse>('/cabinet/admin/legal-pages/rules', data);
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
getFaq: async (): Promise<FaqResponse> => {
|
||||||
|
const response = await apiClient.get<FaqResponse>('/cabinet/admin/legal-pages/faq');
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
updateFaq: async (data: FaqUpdateRequest): Promise<FaqResponse> => {
|
||||||
|
const response = await apiClient.put<FaqResponse>('/cabinet/admin/legal-pages/faq', data);
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
createFaqPage: async (data: FaqPageCreateRequest): Promise<FaqPageItem> => {
|
||||||
|
const response = await apiClient.post<FaqPageItem>(
|
||||||
|
'/cabinet/admin/legal-pages/faq/pages',
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
updateFaqPage: async (id: number, data: FaqPageUpdateRequest): Promise<FaqPageItem> => {
|
||||||
|
const response = await apiClient.put<FaqPageItem>(
|
||||||
|
`/cabinet/admin/legal-pages/faq/pages/${id}`,
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
deleteFaqPage: async (id: number): Promise<void> => {
|
||||||
|
await apiClient.delete(`/cabinet/admin/legal-pages/faq/pages/${id}`);
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -37,6 +37,13 @@ export interface LanguageInfo {
|
|||||||
flag: string;
|
flag: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface InfoVisibility {
|
||||||
|
faq: boolean;
|
||||||
|
rules: boolean;
|
||||||
|
privacy: boolean;
|
||||||
|
offer: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export const infoApi = {
|
export const infoApi = {
|
||||||
// Get FAQ pages list
|
// Get FAQ pages list
|
||||||
getFaqPages: async (): Promise<FaqPage[]> => {
|
getFaqPages: async (): Promise<FaqPage[]> => {
|
||||||
@@ -99,4 +106,9 @@ export const infoApi = {
|
|||||||
const response = await apiClient.get<SupportConfig>('/cabinet/info/support-config');
|
const response = await apiClient.get<SupportConfig>('/cabinet/info/support-config');
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getVisibility: async (): Promise<InfoVisibility> => {
|
||||||
|
const response = await apiClient.get<InfoVisibility>('/cabinet/info/visibility');
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ export type InfoPageType = 'page' | 'faq';
|
|||||||
|
|
||||||
export type ReplacesTab = 'faq' | 'rules' | 'privacy' | 'offer';
|
export type ReplacesTab = 'faq' | 'rules' | 'privacy' | 'offer';
|
||||||
|
|
||||||
|
export type InfoPageDisplayMode = 'bot' | 'web' | 'both';
|
||||||
|
|
||||||
export interface InfoPage {
|
export interface InfoPage {
|
||||||
id: number;
|
id: number;
|
||||||
slug: string;
|
slug: string;
|
||||||
@@ -14,6 +16,7 @@ export interface InfoPage {
|
|||||||
sort_order: number;
|
sort_order: number;
|
||||||
icon: string | null;
|
icon: string | null;
|
||||||
replaces_tab: ReplacesTab | null;
|
replaces_tab: ReplacesTab | null;
|
||||||
|
display_mode: InfoPageDisplayMode;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
updated_at: string | null;
|
updated_at: string | null;
|
||||||
}
|
}
|
||||||
@@ -27,6 +30,7 @@ export interface InfoPageListItem {
|
|||||||
sort_order: number;
|
sort_order: number;
|
||||||
icon: string | null;
|
icon: string | null;
|
||||||
replaces_tab: ReplacesTab | null;
|
replaces_tab: ReplacesTab | null;
|
||||||
|
display_mode: InfoPageDisplayMode;
|
||||||
updated_at: string | null;
|
updated_at: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,6 +43,7 @@ export interface InfoPageCreateRequest {
|
|||||||
sort_order: number;
|
sort_order: number;
|
||||||
icon: string | null;
|
icon: string | null;
|
||||||
replaces_tab: ReplacesTab | null;
|
replaces_tab: ReplacesTab | null;
|
||||||
|
display_mode?: InfoPageDisplayMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface InfoPageUpdateRequest {
|
export interface InfoPageUpdateRequest {
|
||||||
@@ -50,6 +55,7 @@ export interface InfoPageUpdateRequest {
|
|||||||
sort_order?: number;
|
sort_order?: number;
|
||||||
icon?: string | null;
|
icon?: string | null;
|
||||||
replaces_tab?: ReplacesTab | null;
|
replaces_tab?: ReplacesTab | null;
|
||||||
|
display_mode?: InfoPageDisplayMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TabReplacements = Record<ReplacesTab, string | null>;
|
export type TabReplacements = Record<ReplacesTab, string | null>;
|
||||||
|
|||||||
Reference in New Issue
Block a user