feat(#8): Handle polymorphic activity source
This commit is contained in:
@@ -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">—</span>
|
||||
</template>
|
||||
Reference in New Issue
Block a user