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
+3 -5
View File
@@ -4,6 +4,7 @@ import { useState, useEffect, useMemo } from 'react';
import { useInventoryStore } from '@/store/useInventoryStore';
import { isKiller } from '../../lib/utils';
import { DB_BASE_URL, fetchCharacters } from '../../lib/db';
import shared from '../../styles/shared.module.css';
import styles from '../../styles/Characters.module.css';
@@ -16,7 +17,7 @@ type Character = {
const getIconUrl = (iconFilePath: string) => {
const fileName = iconFilePath.split('/').pop()?.split('.')[0];
return `/icons/character-icons/${fileName}.png`;
return `${DB_BASE_URL}/icons/character-icons/${fileName}.png`;
};
type RoleFilter = 'all' | 'survivors' | 'killers';
@@ -29,10 +30,7 @@ export default function CharactersPage() {
const [role, setRole] = useState<RoleFilter>('all');
useEffect(() => {
fetch('/data/characters.json')
.then(r => r.json())
.then(setCharacters)
.catch(() => []);
fetchCharacters().then(setCharacters);
}, []);
const filtered = useMemo(() => {