feat: use new db site, cache requests to avoid repeated unneeded fetch calls

This commit is contained in:
2026-06-18 23:20:12 -03:00
parent 9f5b8cd1fa
commit 6a064d295e
8 changed files with 64 additions and 35 deletions
+6 -7
View File
@@ -7,6 +7,7 @@ import shared from '../../styles/shared.module.css';
import styles from '../../styles/Items.module.css';
import { Item, Offering } from './types';
import { fetchItems, fetchOfferings } from '../../lib/db';
import ItemGrid from './ItemGrid';
import OfferingGrid from './OfferingGrid';
@@ -23,13 +24,11 @@ export default function ItemsPage() {
const [randMax, setRandMax] = useState(200);
useEffect(() => {
Promise.all([
fetch('/data/items.json').then(r => r.json()).catch(() => []),
fetch('/data/offerings.json').then(r => r.json()).catch(() => []),
]).then(([i, o]) => {
setItems(i);
setOfferings(o);
});
Promise.all([fetchItems(), fetchOfferings()])
.then(([i, o]) => {
setItems(i);
setOfferings(o);
});
}, []);
const handleClearAll = () => {