mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 02:23:47 +00:00
- Remove legacy .eslintrc.cjs and .eslintignore - Add eslint.config.js with flat config, security rules (no-eval, no-implied-eval, no-new-func, no-script-url) - Add .prettierrc and .prettierignore - Format entire codebase with prettier
80 lines
2.0 KiB
TypeScript
80 lines
2.0 KiB
TypeScript
import apiClient from './client';
|
|
|
|
export interface SettingCategoryRef {
|
|
key: string;
|
|
label: string;
|
|
}
|
|
|
|
export interface SettingCategorySummary {
|
|
key: string;
|
|
label: string;
|
|
description: string;
|
|
items: number;
|
|
}
|
|
|
|
export interface SettingChoice {
|
|
value: unknown;
|
|
label: string;
|
|
description?: string | null;
|
|
}
|
|
|
|
export interface SettingHint {
|
|
description: string;
|
|
format: string;
|
|
example: string;
|
|
warning: string;
|
|
}
|
|
|
|
export interface SettingDefinition {
|
|
key: string;
|
|
name: string;
|
|
category: SettingCategoryRef;
|
|
type: string;
|
|
is_optional: boolean;
|
|
current: unknown;
|
|
original: unknown;
|
|
has_override: boolean;
|
|
read_only: boolean;
|
|
choices: SettingChoice[];
|
|
hint?: SettingHint | null;
|
|
}
|
|
|
|
export const adminSettingsApi = {
|
|
// Get list of setting categories
|
|
getCategories: async (): Promise<SettingCategorySummary[]> => {
|
|
const response = await apiClient.get<SettingCategorySummary[]>(
|
|
'/cabinet/admin/settings/categories',
|
|
);
|
|
return response.data;
|
|
},
|
|
|
|
// Get all settings or settings for a specific category
|
|
getSettings: async (categoryKey?: string): Promise<SettingDefinition[]> => {
|
|
const params = categoryKey ? { category_key: categoryKey } : {};
|
|
const response = await apiClient.get<SettingDefinition[]>('/cabinet/admin/settings', {
|
|
params,
|
|
});
|
|
return response.data;
|
|
},
|
|
|
|
// Get a specific setting by key
|
|
getSetting: async (key: string): Promise<SettingDefinition> => {
|
|
const response = await apiClient.get<SettingDefinition>(`/cabinet/admin/settings/${key}`);
|
|
return response.data;
|
|
},
|
|
|
|
// Update a setting value
|
|
updateSetting: async (key: string, value: unknown): Promise<SettingDefinition> => {
|
|
const response = await apiClient.put<SettingDefinition>(`/cabinet/admin/settings/${key}`, {
|
|
value,
|
|
});
|
|
return response.data;
|
|
},
|
|
|
|
// Reset a setting to default
|
|
resetSetting: async (key: string): Promise<SettingDefinition> => {
|
|
const response = await apiClient.delete<SettingDefinition>(`/cabinet/admin/settings/${key}`);
|
|
return response.data;
|
|
},
|
|
};
|