rule book ui
This commit is contained in:
@@ -8,7 +8,15 @@ export type Character = CharacterResponse
|
||||
export const useCharactersStore = defineStore('characters', () => {
|
||||
const characters = ref<Character[]>([]);
|
||||
|
||||
const findById = (characterId: number): Character | undefined => characters.value.find(c => c.characterId === characterId);
|
||||
const findById = async (characterId: number): Promise<Character | undefined> => {
|
||||
let character = characters.value.find(c => c.characterId === characterId);
|
||||
|
||||
if (!character) {
|
||||
await refresh(); // TODO call api instead of refresh
|
||||
character = characters.value.find(c => c.characterId === characterId);
|
||||
}
|
||||
return character;
|
||||
}
|
||||
|
||||
const refresh = () => characterControllerApi.getCharacters().then(response => characters.value = response.data);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user