frontend: refactor of the new build viewer

extracting the logic into composables
This commit is contained in:
2026-02-28 13:29:33 +01:00
parent 20ccb20738
commit 7833780bcb
5 changed files with 241 additions and 152 deletions

View File

@@ -0,0 +1,33 @@
/**
* Composable for fetching and managing summoner spell data from CDragon API
* Returns a reactive Map of spell ID to spell data
*/
export const useSummonerSpellMap = () => {
const { data: summonerSpellsData } = useFetch<Array<SummonerSpell>>(
'/api/cdragon/summoner-spells',
{
lazy: true,
server: false
}
)
const summonerSpellMap = ref<Map<number, SummonerSpell>>(new Map())
watch(
summonerSpellsData,
(newData) => {
if (Array.isArray(newData)) {
const map = new Map<number, SummonerSpell>()
for (const spell of newData) {
if (spell?.id) {
map.set(spell.id, spell)
}
}
summonerSpellMap.value = map
}
},
{ immediate: true }
)
return { summonerSpellMap }
}