chore: add settings
This commit is contained in:
@@ -656,3 +656,33 @@ export const deleteCategoryAdmin = async (
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// ============================================
|
||||
// PARAMÈTRES GLOBAUX
|
||||
// ============================================
|
||||
|
||||
export interface AppSettings {
|
||||
penalties_enabled: boolean;
|
||||
points_categories: string[];
|
||||
points_separated: boolean;
|
||||
}
|
||||
|
||||
export const getSettings = async (): Promise<{ success: boolean; settings?: AppSettings; error?: string }> => {
|
||||
try {
|
||||
const { data } = await apiClient.get(`${V2}/admin/protected/settings`);
|
||||
return { success: true, settings: data.settings };
|
||||
} catch (error: any) {
|
||||
return { success: false, error: error.response?.data?.error || "Erreur" };
|
||||
}
|
||||
};
|
||||
|
||||
export const updateSettings = async (
|
||||
settings: AppSettings,
|
||||
): Promise<{ success: boolean; settings?: AppSettings; error?: string }> => {
|
||||
try {
|
||||
const { data } = await apiClient.put(`${V2}/admin/protected/settings`, settings);
|
||||
return { success: true, settings: data.settings };
|
||||
} catch (error: any) {
|
||||
return { success: false, error: error.response?.data?.error || "Erreur" };
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user