feat(#8): Handle polymorphic activity source

This commit is contained in:
Sirttas
2026-07-03 14:00:42 +02:00
parent 052a0a5d03
commit 8d73fe3ed1
8 changed files with 154 additions and 31 deletions
+32
View File
@@ -0,0 +1,32 @@
<script setup lang="ts">
import {computedAsync} from "@vueuse/core";
import {ActivitySourceResponse, ActivitySourceResponseTypeEnum} from "@/generated/mammon";
import {CharacterLabel, useCharactersStore} from "@/characters";
import {CorporationLabel} from "@/corporations";
interface Props {
source: ActivitySourceResponse;
size?: number;
}
const props = withDefaults(defineProps<Props>(), {
size: 32
});
const charactersStore = useCharactersStore();
const character = computedAsync(async () => {
if (props.source.type === ActivitySourceResponseTypeEnum.Character && props.source.characterId) {
return await charactersStore.findById(props.source.characterId);
}
return undefined;
}, undefined);
</script>
<template>
<CharacterLabel v-if="source.type === ActivitySourceResponseTypeEnum.Character && character" :character="character" :size="size" />
<CorporationLabel v-else-if="source.type === ActivitySourceResponseTypeEnum.Corporation && source.corporationId" :corporation-id="source.corporationId" :division="source.division" :size="size" />
<span v-else class="text-slate-400">&mdash;</span>
</template>