diff --git a/src/pages/rules/ListCharacterRuleBooks.vue b/src/pages/rules/ListCharacterRuleBooks.vue index dc0ea26..2004e19 100644 --- a/src/pages/rules/ListCharacterRuleBooks.vue +++ b/src/pages/rules/ListCharacterRuleBooks.vue @@ -4,9 +4,12 @@ import {Character, CharacterLabel, useCharactersStore} from "@/characters"; import {PencilSquareIcon} from "@heroicons/vue/24/outline"; import {findCharacterRuleBookByCharacterId, useRuleBooksStore} from "@/rules"; import {computedAsync} from "@vueuse/core"; +import {routeNames} from "@/routes.ts"; +import {SortableHeader, useSort} from "@/components/table"; type CharacterRuleBookView = { character: Character; + characterName: string; characterId: number; ruleBookName: string; } @@ -14,26 +17,41 @@ type CharacterRuleBookView = { const {characters} = storeToRefs(useCharactersStore()); const {findById: findRuleBookById} = useRuleBooksStore(); -const list = computedAsync(async () => await Promise.all(characters.value.map(createCharacterRuleBookView)), []) -const createCharacterRuleBookView = async (character: Character): Promise => { +const { sortedArray, headerProps } = useSort(computedAsync(async () => await Promise.all(characters.value.map(async (character: Character): Promise => { const characterRuleBook = await findCharacterRuleBookByCharacterId(character.characterId); const ruleBook = findRuleBookById(characterRuleBook.ruleBookId); return { character, + characterName: character.name, characterId: character.characterId, ruleBookName: ruleBook?.name ?? '' } -} +})), [])) \ No newline at end of file