This commit is contained in:
2026-03-29 19:30:14 +02:00
parent 4757cf47c0
commit eaa0c9b0e0
3 changed files with 19 additions and 4 deletions
+2 -3
View File
@@ -1,9 +1,9 @@
// src/components/Footer/Footer.jsx
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { fetchDatabaseVersion, triggerFullImport } from '../../services/api'; import { fetchDatabaseVersion, triggerFullImport } from '../../services/api';
function DatabaseFooter() { function Footer() {
const [dbVersion, setDbVersion] = useState(null); const [dbVersion, setDbVersion] = useState(null);
const [loading, setLoading] = useState(false);
const [importing, setImporting] = useState(false); const [importing, setImporting] = useState(false);
const [error, setError] = useState(null); const [error, setError] = useState(null);
@@ -19,7 +19,6 @@ function DatabaseFooter() {
setError(null); setError(null);
try { try {
await triggerFullImport(); await triggerFullImport();
// After import, refresh DB version
const data = await fetchDatabaseVersion(); const data = await fetchDatabaseVersion();
setDbVersion(data.database_version); setDbVersion(data.database_version);
} catch (err) { } catch (err) {
+2 -1
View File
@@ -1,10 +1,11 @@
//HomePage.jsx
import React, { useEffect, useState, useContext } from 'react'; import React, { useEffect, useState, useContext } from 'react';
import { Virtuoso } from 'react-virtuoso'; import { Virtuoso } from 'react-virtuoso';
import CardRow from '../components/CardRow/CardRow'; import CardRow from '../components/CardRow/CardRow';
import SearchBar from '../components/SearchBar/SearchBar'; import SearchBar from '../components/SearchBar/SearchBar';
import { CardContext } from '../store/CardContext'; import { CardContext } from '../store/CardContext';
import { fetchCards, fetchCardImage } from '../services/api'; import { fetchCards, fetchCardImage } from '../services/api';
import DatabaseFooter from '../components/Footer/Footer'; import Footer from '../components/Footer/Footer';
// Debounce hook // Debounce hook
function useDebouncedValue(value, delay = 250) { function useDebouncedValue(value, delay = 250) {
+15
View File
@@ -1,3 +1,4 @@
//api.jsx
const API_BASE = '/api'; const API_BASE = '/api';
export async function fetchCards() { export async function fetchCards() {
@@ -28,3 +29,17 @@ export async function updateCardAmount(cardId, setId, rarityId, amount) {
if (!response.ok) throw new Error('Failed to update amount'); if (!response.ok) throw new Error('Failed to update amount');
return await response.json(); 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();
}