From d38b31d954f2a678383d3e9b23ae5329801f52fc Mon Sep 17 00:00:00 2001 From: Syco21 Date: Fri, 27 Mar 2026 19:44:27 +0100 Subject: [PATCH] LXC Url --- src/pages/HomePage.jsx | 10 ++++------ src/services/api.jsx | 9 ++++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/pages/HomePage.jsx b/src/pages/HomePage.jsx index d2d8042..baa50bb 100644 --- a/src/pages/HomePage.jsx +++ b/src/pages/HomePage.jsx @@ -2,8 +2,8 @@ import React, { useEffect, useState, useContext } from 'react'; import { Virtuoso } from 'react-virtuoso'; import CardRow from '../components/CardRow/CardRow'; import SearchBar from '../components/SearchBar/SearchBar'; -import { fetchCards } from '../services/api'; import { CardContext } from '../store/CardContext'; +import { fetchCards, fetchCardImage } from '../services/api'; // Debounce hook function useDebouncedValue(value, delay = 250) { @@ -34,14 +34,12 @@ function HomePage() { }, []); // Load image for the currently expanded card + useEffect(() => { if (!expandedCardId || cardImages[expandedCardId]) return; - fetch(`http://localhost:3000/cardImage/${expandedCardId}`) - .then(res => res.json()) - .then(data => { - if (data.image) setCardImage(expandedCardId, data.image); - }) + fetchCardImage(expandedCardId) + .then(image => setCardImage(expandedCardId, image)) .catch(err => console.error('Failed to load card image', err)); }, [expandedCardId, cardImages, setCardImage]); diff --git a/src/services/api.jsx b/src/services/api.jsx index de25629..661c333 100644 --- a/src/services/api.jsx +++ b/src/services/api.jsx @@ -1,7 +1,14 @@ -const API_BASE = 'http://localhost:3000'; // Backend URL +const API_BASE = 'http://192.168.178.41:3000'; // Backend URL export async function fetchCards() { const response = await fetch(`${API_BASE}/exportCards`); if (!response.ok) throw new Error('Failed to fetch cards'); return await response.json(); } + +export async function fetchCardImage(cardId) { + const response = await fetch(`${API_BASE}/cardImage/${cardId}`); + if (!response.ok) throw new Error('Failed to fetch card image'); + const data = await response.json(); + return data.image; +} \ No newline at end of file