Nueva funcionalidad

This commit is contained in:
2026-02-19 11:34:03 -06:00
parent f00a32ddb3
commit bcc758953f
14 changed files with 729 additions and 220 deletions

View File

@@ -19,6 +19,8 @@ export interface HelpArticle {
content: string;
updated_at: string;
last_editor: string;
category?: string;
order?: number;
}
export const helpApi = {
@@ -44,7 +46,7 @@ export const helpApi = {
return response.json();
},
async createArticle(data: { title: string; content: string; slug: string; last_editor: string }): Promise<HelpArticle> {
async createArticle(data: { title: string; content: string; slug: string; last_editor: string; category?: string; order?: number }): Promise<HelpArticle> {
const response = await fetch(`${BASE_URL}/articles/`, {
method: 'POST',
headers: getHeaders(),
@@ -64,5 +66,21 @@ export const helpApi = {
async triggerSync(): Promise<void> {
// Opcional: endpoint para forzar sync desde UI si es necesario
},
async uploadImage(file: File): Promise<{ url: string }> {
const formData = new FormData();
formData.append('file', file);
const response = await fetch(`${BASE_URL}/upload-image/`, {
method: 'POST',
// No Content-Type header for FormData, browser sets it with boundary
headers: {
...(get(authStore).token ? { 'Authorization': `Bearer ${get(authStore).token}` } : {})
},
body: formData
});
if (!response.ok) throw new Error('Failed to upload image');
return response.json();
}
};