diff --git a/src/components/crapp/Avatar.tsx b/src/components/crapp/Avatar.tsx index 1ab7039..c29ffba 100644 --- a/src/components/crapp/Avatar.tsx +++ b/src/components/crapp/Avatar.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; import { cn } from "@/lib/utils"; -import { urlAvatar } from "@/lib/avatar-store"; +import { urlAvatarDaRiga, useAvatarMap } from "@/lib/avatar-store"; export function Avatar({ id, @@ -19,8 +19,12 @@ export function Avatar({ const [errore, setErrore] = useState(false); useEffect(() => setErrore(false), [id, bust]); - if (!errore) { - const src = bust ? `${urlAvatar(id)}?v=${bust}` : urlAvatar(id); + const { data: mappa } = useAvatarMap(); + const riga = mappa?.[id]; + + if (riga && !errore) { + const base = urlAvatarDaRiga(riga); + const src = bust ? `${base}?v=${bust}` : base; return ( Promise; + onCaricato: (risultato: { id: string; filename: string }) => Promise; }) { const input = useRef(null); const [inCorso, setInCorso] = useState(false); @@ -53,7 +55,7 @@ function CampoFile({ if (!file) return; setInCorso(true); try { - const nuovo = await caricaFile(giocatoreId, sezione, file, path); + const nuovo = await caricaFile(giocatoreId, sezione, file); await onCaricato(nuovo); toast.success(`${label} caricato`); } catch (errore) { @@ -77,10 +79,10 @@ function CampoFile({ {label} - {path ? ( + {path && recordId ? (