mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 10:27:49 +00:00
refactor: migrate to eslint flat config and format codebase with prettier
- 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
This commit is contained in:
@@ -1,73 +1,79 @@
|
||||
import apiClient from './client'
|
||||
import apiClient from './client';
|
||||
|
||||
export interface SettingCategoryRef {
|
||||
key: string
|
||||
label: string
|
||||
key: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface SettingCategorySummary {
|
||||
key: string
|
||||
label: string
|
||||
description: string
|
||||
items: number
|
||||
key: string;
|
||||
label: string;
|
||||
description: string;
|
||||
items: number;
|
||||
}
|
||||
|
||||
export interface SettingChoice {
|
||||
value: unknown
|
||||
label: string
|
||||
description?: string | null
|
||||
value: unknown;
|
||||
label: string;
|
||||
description?: string | null;
|
||||
}
|
||||
|
||||
export interface SettingHint {
|
||||
description: string
|
||||
format: string
|
||||
example: string
|
||||
warning: string
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
const response = await apiClient.delete<SettingDefinition>(`/cabinet/admin/settings/${key}`);
|
||||
return response.data;
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user