Fix apiFetch: update remaining files + add .next-build to .gitignore
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 <noreply@anthropic.com>
This commit is contained in:
parent
bebe2ac390
commit
62ea9011a0
11 changed files with 37 additions and 26 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -48,3 +48,4 @@ Thumbs.db
|
|||
*.mov
|
||||
*.wmv
|
||||
|
||||
frontend/.next-build/
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 }),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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<PresentationResponse[]> {
|
||||
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",
|
||||
|
|
|
|||
|
|
@ -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<PreviousGeneratedImagesResponse[]> => {
|
||||
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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue