ppt-tool/frontend/app/(presentation-generator)/services/api/dashboard.ts
Vadym Samoilenko 69a8829750 Phase 3: Bug fixes, feature enhancements, and polish
P0 Critical: presentation isolation (client scoping), storage super_admin fix,
template selection in worker, IMAGE_PROVIDERS list fix.

P1 High: template layout management UI (delete/filter/bulk), slide-based parsing
mode, LLM model listing & connection test, settings persistence to DB (Fernet
encryption), logout button.

P2 Polish: storage improvements (master deck files, per-client breakdown, bulk
delete, hard purge, client selector), image generation error visibility
(__image_error__ badge), hamster wheel loading animation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 12:58:52 +00:00

86 lines
2.2 KiB
TypeScript

import {
getHeader,
} from "@/app/(presentation-generator)/services/api/header";
import { ApiResponseHandler } from "@/app/(presentation-generator)/services/api/api-error-handler";
export interface PresentationResponse {
id: string;
title: string;
created_at: string;
updated_at: string;
data: any | null;
file: string;
n_slides: number;
prompt: string;
summary: string | null;
theme: string;
titles: string[];
user_id: string;
vector_store: any;
thumbnail: string;
slides: any[];
}
export class DashboardApi {
static async getPresentations(clientId?: string): Promise<PresentationResponse[]> {
try {
const params = clientId ? `?client_id=${clientId}` : '';
const response = await fetch(
`/api/v1/ppt/presentation/all${params}`,
{
method: "GET",
headers: getHeader(),
}
);
// Handle the special case where 404 means "no presentations found"
if (response.status === 404) {
console.log("No presentations found");
return [];
}
return await ApiResponseHandler.handleResponse(response, "Failed to fetch presentations");
} catch (error) {
console.error("Error fetching presentations:", error);
throw error;
}
}
static async getPresentation(id: string) {
try {
const response = await fetch(
`/api/v1/ppt/presentation/${id}`,
{
method: "GET",
}
);
return await ApiResponseHandler.handleResponse(response, "Presentation not found");
} catch (error) {
console.error("Error fetching presentation:", error);
throw error;
}
}
static async deletePresentation(presentation_id: string) {
try {
const response = await fetch(
`/api/v1/ppt/presentation/${presentation_id}`,
{
method: "DELETE",
headers: getHeader(),
}
);
return await ApiResponseHandler.handleResponseWithResult(response, "Failed to delete presentation");
} catch (error) {
console.error("Error deleting presentation:", error);
return {
success: false,
message: error instanceof Error ? error.message : "Failed to delete presentation",
};
}
}
}