From 62ea9011a069bd9ee6ca0d4d02c6bde4b0e62ff4 Mon Sep 17 00:00:00 2001 From: Vadym Samoilenko Date: Thu, 19 Mar 2026 22:24:42 +0000 Subject: [PATCH] Fix apiFetch: update remaining files + add .next-build to .gitignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit authSlice, clientSlice, custom-template hooks, dashboard/presentation-generation services and CustomConfig — all /api/v1/ calls now route through apiFetch. Co-Authored-By: Claude Sonnet 4.6 --- .gitignore | 1 + .../components/TemplateCodegenExport.tsx | 3 ++- .../hooks/useFontManagement.ts | 3 ++- .../custom-template/hooks/useLayoutSaving.ts | 5 +++-- .../custom-template/hooks/useSlideEdit.ts | 3 ++- .../hooks/useSlideProcessing.ts | 7 ++++--- .../services/api/dashboard.ts | 7 ++++--- .../services/api/presentation-generation.ts | 21 ++++++++++--------- frontend/components/CustomConfig.tsx | 3 ++- frontend/store/slices/authSlice.ts | 7 ++++--- frontend/store/slices/clientSlice.ts | 3 ++- 11 files changed, 37 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index b24d71e..aeb9fa5 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,4 @@ Thumbs.db *.mov *.wmv +frontend/.next-build/ diff --git a/frontend/app/(presentation-generator)/components/TemplateCodegenExport.tsx b/frontend/app/(presentation-generator)/components/TemplateCodegenExport.tsx index 551ac19..85a8fc6 100644 --- a/frontend/app/(presentation-generator)/components/TemplateCodegenExport.tsx +++ b/frontend/app/(presentation-generator)/components/TemplateCodegenExport.tsx @@ -1,6 +1,7 @@ "use client"; import React, { useCallback, useRef, useState } from "react"; +import { apiFetch } from '../../../lib/apiFetch'; import { Button } from "@/components/ui/button"; import { Upload, X, FileText, Loader2, CheckCircle } from "lucide-react"; @@ -49,7 +50,7 @@ export function TemplateCodegenExport({ presentationId, onClose }: TemplateCodeg form.append("custom_prompt", customPrompt.trim()); } - const response = await fetch("/api/v1/ppt/template-codegen/generate", { + const response = await apiFetch("/api/v1/ppt/template-codegen/generate", { method: "POST", body: form, }); diff --git a/frontend/app/(presentation-generator)/custom-template/hooks/useFontManagement.ts b/frontend/app/(presentation-generator)/custom-template/hooks/useFontManagement.ts index a9714a0..0ecade0 100644 --- a/frontend/app/(presentation-generator)/custom-template/hooks/useFontManagement.ts +++ b/frontend/app/(presentation-generator)/custom-template/hooks/useFontManagement.ts @@ -1,4 +1,5 @@ import { useState, useEffect, useCallback } from "react"; +import { apiFetch } from '../../../../lib/apiFetch'; import { toast } from "sonner"; import { UploadedFont, FontData } from "../types"; @@ -82,7 +83,7 @@ export const useFontManagement = () => { const formData = new FormData(); formData.append("font_file", file); - const response = await fetch("/api/v1/ppt/fonts/upload", { + const response = await apiFetch("/api/v1/ppt/fonts/upload", { method: "POST", body: formData, }); diff --git a/frontend/app/(presentation-generator)/custom-template/hooks/useLayoutSaving.ts b/frontend/app/(presentation-generator)/custom-template/hooks/useLayoutSaving.ts index 0dd617b..9287c44 100644 --- a/frontend/app/(presentation-generator)/custom-template/hooks/useLayoutSaving.ts +++ b/frontend/app/(presentation-generator)/custom-template/hooks/useLayoutSaving.ts @@ -1,4 +1,5 @@ import { useState, useCallback } from "react"; +import { apiFetch } from '../../../../lib/apiFetch'; import { toast } from "sonner"; import { v4 as uuidv4 } from "uuid"; import { ApiResponseHandler } from "@/app/(presentation-generator)/services/api/api-error-handler"; @@ -35,7 +36,7 @@ export const useLayoutSaving = ( while (retryCount < maxRetries) { try { - const response = await fetch("/api/v1/ppt/html-to-react/", { + const response = await apiFetch("/api/v1/ppt/html-to-react/", { method: "POST", headers: { "Content-Type": "application/json", @@ -136,7 +137,7 @@ export const useLayoutSaving = ( } // First create/update the template metadata - await fetch("/api/v1/ppt/template-management/templates", { + await apiFetch("/api/v1/ppt/template-management/templates", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ id: presentationId, name: layoutName, description }), diff --git a/frontend/app/(presentation-generator)/custom-template/hooks/useSlideEdit.ts b/frontend/app/(presentation-generator)/custom-template/hooks/useSlideEdit.ts index 7ab1d4c..ff13a5f 100644 --- a/frontend/app/(presentation-generator)/custom-template/hooks/useSlideEdit.ts +++ b/frontend/app/(presentation-generator)/custom-template/hooks/useSlideEdit.ts @@ -1,4 +1,5 @@ import { useState, useEffect, useRef } from "react"; +import { apiFetch } from '../../../../lib/apiFetch'; import html2canvas from "html2canvas"; import { ProcessedSlide } from "../types"; @@ -142,7 +143,7 @@ export const useSlideEdit = ( formData.append("html", currentHtml); formData.append("prompt", prompt); - const response = await fetch("/api/v1/ppt/html-edit/", { + const response = await apiFetch("/api/v1/ppt/html-edit/", { method: "POST", body: formData, }); diff --git a/frontend/app/(presentation-generator)/custom-template/hooks/useSlideProcessing.ts b/frontend/app/(presentation-generator)/custom-template/hooks/useSlideProcessing.ts index bab6401..5b00eef 100644 --- a/frontend/app/(presentation-generator)/custom-template/hooks/useSlideProcessing.ts +++ b/frontend/app/(presentation-generator)/custom-template/hooks/useSlideProcessing.ts @@ -1,4 +1,5 @@ import { useState, useCallback } from "react"; +import { apiFetch } from '../../../../lib/apiFetch'; import { toast } from "sonner"; import { ApiResponseHandler } from "@/app/(presentation-generator)/services/api/api-error-handler"; import { ProcessedSlide, SlideData, FontData } from "../types"; @@ -27,7 +28,7 @@ export const useSlideProcessing = ( ); try { - const htmlResponse = await fetch("/api/v1/ppt/slide-to-html/", { + const htmlResponse = await apiFetch("/api/v1/ppt/slide-to-html/", { method: "POST", headers: { "Content-Type": "application/json", @@ -133,7 +134,7 @@ export const useSlideProcessing = ( let slidesResponseData: any = null; if (isPdf) { formData.append("pdf_file", selectedFile); - const pdfResponse = await fetch("/api/v1/ppt/pdf-slides/process", { + const pdfResponse = await apiFetch("/api/v1/ppt/pdf-slides/process", { method: "POST", body: formData, }); @@ -143,7 +144,7 @@ export const useSlideProcessing = ( ); } else if (isPptx) { formData.append("pptx_file", selectedFile); - const pptxResponse = await fetch("/api/v1/ppt/pptx-slides/process", { + const pptxResponse = await apiFetch("/api/v1/ppt/pptx-slides/process", { method: "POST", body: formData, }); diff --git a/frontend/app/(presentation-generator)/services/api/dashboard.ts b/frontend/app/(presentation-generator)/services/api/dashboard.ts index 33ee886..0b4688b 100644 --- a/frontend/app/(presentation-generator)/services/api/dashboard.ts +++ b/frontend/app/(presentation-generator)/services/api/dashboard.ts @@ -1,4 +1,5 @@ import { +import { apiFetch } from '../../../../lib/apiFetch'; getHeader, } from "@/app/(presentation-generator)/services/api/header"; import { ApiResponseHandler } from "@/app/(presentation-generator)/services/api/api-error-handler"; @@ -27,7 +28,7 @@ export class DashboardApi { static async getPresentations(clientId?: string): Promise { try { const params = clientId ? `?client_id=${clientId}` : ''; - const response = await fetch( + const response = await apiFetch( `/api/v1/ppt/presentation/all${params}`, { method: "GET", @@ -50,7 +51,7 @@ export class DashboardApi { static async getPresentation(id: string) { try { - const response = await fetch( + const response = await apiFetch( `/api/v1/ppt/presentation/${id}`, { method: "GET", @@ -66,7 +67,7 @@ export class DashboardApi { static async deletePresentation(presentation_id: string) { try { - const response = await fetch( + const response = await apiFetch( `/api/v1/ppt/presentation/${presentation_id}`, { method: "DELETE", diff --git a/frontend/app/(presentation-generator)/services/api/presentation-generation.ts b/frontend/app/(presentation-generator)/services/api/presentation-generation.ts index 6c2cc10..18d97e2 100644 --- a/frontend/app/(presentation-generator)/services/api/presentation-generation.ts +++ b/frontend/app/(presentation-generator)/services/api/presentation-generation.ts @@ -1,4 +1,5 @@ import { getHeader, getHeaderForFormData } from "./header"; +import { apiFetch } from '../../../../lib/apiFetch'; import { IconSearch, ImageGenerate, ImageSearch, PreviousGeneratedImagesResponse } from "./params"; import { ApiResponseHandler } from "./api-error-handler"; @@ -11,7 +12,7 @@ export class PresentationGenerationApi { }); try { - const response = await fetch( + const response = await apiFetch( `/api/v1/ppt/files/upload`, { method: "POST", @@ -30,7 +31,7 @@ export class PresentationGenerationApi { static async decomposeDocuments(documentKeys: string[]) { try { - const response = await fetch( + const response = await apiFetch( `/api/v1/ppt/files/decompose`, { method: "POST", @@ -74,7 +75,7 @@ export class PresentationGenerationApi { web_search?: boolean; }) { try { - const response = await fetch( + const response = await apiFetch( `/api/v1/ppt/presentation/create`, { method: "POST", @@ -107,7 +108,7 @@ export class PresentationGenerationApi { prompt: string ) { try { - const response = await fetch( + const response = await apiFetch( `/api/v1/ppt/slide/edit`, { method: "POST", @@ -129,7 +130,7 @@ export class PresentationGenerationApi { static async updatePresentationContent(body: any) { try { - const response = await fetch( + const response = await apiFetch( `/api/v1/ppt/presentation/update`, { method: "PATCH", @@ -148,7 +149,7 @@ export class PresentationGenerationApi { static async presentationPrepare(presentationData: any) { try { - const response = await fetch( + const response = await apiFetch( `/api/v1/ppt/presentation/prepare`, { method: "POST", @@ -170,7 +171,7 @@ export class PresentationGenerationApi { static async generateImage(imageGenerate: ImageGenerate) { try { - const response = await fetch( + const response = await apiFetch( `/api/v1/ppt/images/generate?prompt=${imageGenerate.prompt}`, { method: "GET", @@ -188,7 +189,7 @@ export class PresentationGenerationApi { static getPreviousGeneratedImages = async (): Promise => { try { - const response = await fetch( + const response = await apiFetch( `/api/v1/ppt/images/generated`, { method: "GET", @@ -205,7 +206,7 @@ export class PresentationGenerationApi { static async searchIcons(iconSearch: IconSearch) { try { - const response = await fetch( + const response = await apiFetch( `/api/v1/ppt/icons/search?query=${iconSearch.query}&limit=${iconSearch.limit}`, { method: "GET", @@ -226,7 +227,7 @@ export class PresentationGenerationApi { // EXPORT PRESENTATION static async exportAsPPTX(presentationData: any) { try { - const response = await fetch( + const response = await apiFetch( `/api/v1/ppt/presentation/export/pptx`, { method: "POST", diff --git a/frontend/components/CustomConfig.tsx b/frontend/components/CustomConfig.tsx index 8f7a504..a2ed124 100644 --- a/frontend/components/CustomConfig.tsx +++ b/frontend/components/CustomConfig.tsx @@ -1,5 +1,6 @@ "use client"; import { useState, useEffect } from "react"; +import { apiFetch } from '../lib/apiFetch'; import { Check, ChevronsUpDown, Loader2 } from "lucide-react"; import { Button } from "./ui/button"; import { @@ -60,7 +61,7 @@ export default function CustomConfig({ try { setCustomModelsLoading(true); - const response = await fetch("/api/v1/ppt/openai/models/available", { + const response = await apiFetch("/api/v1/ppt/openai/models/available", { method: "POST", headers: { "Content-Type": "application/json", diff --git a/frontend/store/slices/authSlice.ts b/frontend/store/slices/authSlice.ts index 536975d..6926e47 100644 --- a/frontend/store/slices/authSlice.ts +++ b/frontend/store/slices/authSlice.ts @@ -1,4 +1,5 @@ import { createSlice, createAsyncThunk } from "@reduxjs/toolkit"; +import { apiFetch } from '../../lib/apiFetch'; export interface User { id: string; @@ -26,7 +27,7 @@ export const fetchCurrentUser = createAsyncThunk( "auth/fetchCurrentUser", async (_, { rejectWithValue }) => { try { - const response = await fetch("/api/v1/auth/me"); + const response = await apiFetch("/api/v1/auth/me"); if (response.status === 401) { return rejectWithValue("Not authenticated"); } @@ -44,7 +45,7 @@ export const checkDevMode = createAsyncThunk( "auth/checkDevMode", async () => { try { - const response = await fetch("/api/v1/auth/dev-status"); + const response = await apiFetch("/api/v1/auth/dev-status"); if (response.ok) { const data = await response.json(); return data.dev_mode ?? false; @@ -59,7 +60,7 @@ export const checkDevMode = createAsyncThunk( export const logoutUser = createAsyncThunk( "auth/logoutUser", async () => { - await fetch("/api/v1/auth/logout", { method: "POST" }); + await apiFetch("/api/v1/auth/logout", { method: "POST" }); return true; } ); diff --git a/frontend/store/slices/clientSlice.ts b/frontend/store/slices/clientSlice.ts index 46cfde7..1025004 100644 --- a/frontend/store/slices/clientSlice.ts +++ b/frontend/store/slices/clientSlice.ts @@ -1,4 +1,5 @@ import { createSlice, createAsyncThunk, PayloadAction } from "@reduxjs/toolkit"; +import { apiFetch } from '../../lib/apiFetch'; import { getHeader } from "@/app/(presentation-generator)/services/api/header"; export interface Client { @@ -50,7 +51,7 @@ export const fetchClients = createAsyncThunk( "client/fetchClients", async (_, { rejectWithValue }) => { try { - const response = await fetch("/api/v1/admin/clients", { + const response = await apiFetch("/api/v1/admin/clients", { headers: getHeader(), }); if (!response.ok) return rejectWithValue("Failed to fetch clients");