From eaa0c9b0e0a1e62f752ab6d1b31b14e5f21620ca Mon Sep 17 00:00:00 2001 From: Syco21 Date: Sun, 29 Mar 2026 19:30:14 +0200 Subject: [PATCH] name --- src/components/Footer/Footer.jsx | 5 ++--- src/pages/HomePage.jsx | 3 ++- src/services/api.jsx | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/components/Footer/Footer.jsx b/src/components/Footer/Footer.jsx index 906ed87..fc94d47 100644 --- a/src/components/Footer/Footer.jsx +++ b/src/components/Footer/Footer.jsx @@ -1,9 +1,9 @@ +// src/components/Footer/Footer.jsx import React, { useEffect, useState } from 'react'; import { fetchDatabaseVersion, triggerFullImport } from '../../services/api'; -function DatabaseFooter() { +function Footer() { const [dbVersion, setDbVersion] = useState(null); - const [loading, setLoading] = useState(false); const [importing, setImporting] = useState(false); const [error, setError] = useState(null); @@ -19,7 +19,6 @@ function DatabaseFooter() { setError(null); try { await triggerFullImport(); - // After import, refresh DB version const data = await fetchDatabaseVersion(); setDbVersion(data.database_version); } catch (err) { diff --git a/src/pages/HomePage.jsx b/src/pages/HomePage.jsx index f9c78c1..b7262fe 100644 --- a/src/pages/HomePage.jsx +++ b/src/pages/HomePage.jsx @@ -1,10 +1,11 @@ +//HomePage.jsx 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 { CardContext } from '../store/CardContext'; import { fetchCards, fetchCardImage } from '../services/api'; -import DatabaseFooter from '../components/Footer/Footer'; +import Footer from '../components/Footer/Footer'; // Debounce hook function useDebouncedValue(value, delay = 250) { diff --git a/src/services/api.jsx b/src/services/api.jsx index bf7043d..cc4d87e 100644 --- a/src/services/api.jsx +++ b/src/services/api.jsx @@ -1,3 +1,4 @@ +//api.jsx const API_BASE = '/api'; export async function fetchCards() { @@ -27,4 +28,18 @@ export async function updateCardAmount(cardId, setId, rarityId, amount) { if (!response.ok) throw new Error('Failed to update amount'); return await response.json(); +} + +export async function fetchDatabaseVersion() { + const response = await fetch(`${API_BASE}/db-version`); + if (!response.ok) throw new Error('Failed to fetch database version'); + return await response.json(); +} + +export async function triggerFullImport() { + const response = await fetch(`${API_BASE}/import/full-import`, { + method: 'POST' + }); + if (!response.ok) throw new Error('Failed to trigger full import'); + return await response.json(); } \ No newline at end of file