From 56a94c843984a4db198bcdda88c3e0e011d9a27a Mon Sep 17 00:00:00 2001 From: Xor290 Date: Sat, 23 May 2026 16:45:02 +0200 Subject: [PATCH] chore: build --- frontend-admin/src/api/client.ts | 5 +++-- frontend-prep/src/api/api.ts | 37 ++++++++++++++++++++++++-------- mobile/src/api/api.ts | 3 --- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/frontend-admin/src/api/client.ts b/frontend-admin/src/api/client.ts index 921186d9..1ff3f905 100644 --- a/frontend-admin/src/api/client.ts +++ b/frontend-admin/src/api/client.ts @@ -1,7 +1,8 @@ import axios from "axios"; import { getToken, getAdminToken } from "../auth/tokenStorage"; -export const API_BASE_URL = process.env.EXPO_PUBLIC_API_URL ?? "https://mln-uber.club"; +export const API_BASE_URL = + process.env.EXPO_PUBLIC_API_URL ?? "https://mln-uber.club"; const apiClient = axios.create({ baseURL: API_BASE_URL, @@ -11,7 +12,7 @@ const apiClient = axios.create({ }, }); -// Request interceptor: attach JWT token +// attach JWT token apiClient.interceptors.request.use(async (config) => { const isAdminRoute = config.url?.includes("/api/v2/") || diff --git a/frontend-prep/src/api/api.ts b/frontend-prep/src/api/api.ts index 49e355d1..5487d6fe 100644 --- a/frontend-prep/src/api/api.ts +++ b/frontend-prep/src/api/api.ts @@ -1,9 +1,7 @@ // ============================================ // api/api.ts - VERSION CORRIGÉE // ============================================ -// ✅ AuthResponse inclut access_token -// ✅ loginUser et registerUser retournent AuthResponse -// ✅ sessionStorage (pas localStorage) + const API_URL = "/api/v1"; const BACKEND_URL = ""; export function getMediaUrl(url: string): string { @@ -1949,29 +1947,50 @@ export const verify2FA = async ( user: data.user, }; } catch (error) { - return { success: false, message: error instanceof Error ? error.message : "Erreur" }; + return { + success: false, + message: error instanceof Error ? error.message : "Erreur", + }; } }; -export const get2FAStatus = async (): Promise<{ two_fa_enabled: boolean; telegram_linked: boolean; admin_2fa_enabled: boolean }> => { +export const get2FAStatus = async (): Promise<{ + two_fa_enabled: boolean; + telegram_linked: boolean; + admin_2fa_enabled: boolean; +}> => { const token = sessionStorage.getItem("token"); try { const response = await fetch(`${API_URL}/two-fa/status`, { headers: { Authorization: `Bearer ${token}` }, }); - if (!response.ok) return { two_fa_enabled: false, telegram_linked: false, admin_2fa_enabled: false }; + if (!response.ok) + return { + two_fa_enabled: false, + telegram_linked: false, + admin_2fa_enabled: false, + }; return await safeJson(response); } catch { - return { two_fa_enabled: false, telegram_linked: false, admin_2fa_enabled: false }; + return { + two_fa_enabled: false, + telegram_linked: false, + admin_2fa_enabled: false, + }; } }; -export const toggle2FA = async (enabled: boolean): Promise<{ success: boolean; error?: string }> => { +export const toggle2FA = async ( + enabled: boolean, +): Promise<{ success: boolean; error?: string }> => { const token = sessionStorage.getItem("token"); try { const response = await fetch(`${API_URL}/two-fa/toggle`, { method: "POST", - headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` }, + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${token}`, + }, body: JSON.stringify({ enabled }), }); const data = await safeJson(response); diff --git a/mobile/src/api/api.ts b/mobile/src/api/api.ts index 54e24100..7ca72413 100644 --- a/mobile/src/api/api.ts +++ b/mobile/src/api/api.ts @@ -157,9 +157,6 @@ export const getProductById = async (id: number) => { } }; -// ============================================ -// CART - export const getCart = async (username: string) => { const jwtUsername = await getJwtUsername(); if (!jwtUsername || jwtUsername !== username) {