From 37f770a09a8659dc60e19836c4c9c9dc2c28e1f1 Mon Sep 17 00:00:00 2001 From: OpenSquared Date: Wed, 24 Jun 2026 18:13:47 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20Timeline=20=E2=80=94=20utiliser=20axios?= =?UTF-8?q?=20/api=20relatif=20au=20lieu=20de=20fetch=20localhost:8000?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les appels fetch vers http://localhost:8000 ne fonctionnent pas en déploiement Docker — remplacé par axios avec baseURL='/api' comme le reste de l'app. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/pages/Timeline.tsx | 43 +++++++++++++++++---------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/frontend/src/pages/Timeline.tsx b/frontend/src/pages/Timeline.tsx index c1ce77d..07d2aef 100644 --- a/frontend/src/pages/Timeline.tsx +++ b/frontend/src/pages/Timeline.tsx @@ -1,8 +1,9 @@ import { useState, useEffect, useCallback } from 'react' import { ChevronLeft, ChevronRight, Sparkles, Calendar, Clock, Layers, RefreshCw } from 'lucide-react' +import axios from 'axios' import clsx from 'clsx' -const API = 'http://localhost:8000' +const api = axios.create({ baseURL: '/api' }) interface MarketEvent { id: number @@ -231,42 +232,42 @@ export default function Timeline() { const fetchDay = useCallback(async (d: string) => { setLoading(true) try { - const res = await fetch(`${API}/api/timeline/day/${d}`) - if (res.ok) setCtx(await res.json()) - } finally { + const res = await api.get(`/timeline/day/${d}`) + setCtx(res.data) + } catch { /* ignore */ } finally { setLoading(false) } }, []) const fetchEvents = useCallback(async () => { - const res = await fetch(`${API}/api/timeline/events`) - if (res.ok) setAllEvents(await res.json()) + try { + const res = await api.get('/timeline/events') + setAllEvents(res.data) + } catch { /* ignore */ } }, []) const bootstrap = useCallback(async () => { - const res = await fetch(`${API}/api/timeline/bootstrap`, { method: 'POST' }) - if (res.ok) { + try { + await api.post('/timeline/bootstrap') setBootstrapped(true) await fetchEvents() await fetchDay(refDate) - } + } catch { /* ignore */ } }, [refDate, fetchDay, fetchEvents]) const generateAI = useCallback(async () => { setGenerating(true) try { - const res = await fetch(`${API}/api/timeline/generate/${refDate}`, { method: 'POST' }) - if (res.ok) { - const data = await res.json() - setCtx(prev => prev ? { - ...prev, - long_commentary: data.long_commentary, - medium_commentary: data.medium_commentary, - short_commentary: data.short_commentary, - has_commentary: true, - } : prev) - } - } finally { + const res = await api.post(`/timeline/generate/${refDate}`) + const data = res.data + setCtx(prev => prev ? { + ...prev, + long_commentary: data.long_commentary, + medium_commentary: data.medium_commentary, + short_commentary: data.short_commentary, + has_commentary: true, + } : prev) + } catch { /* ignore */ } finally { setGenerating(false) } }, [refDate])