game-village-politics-frontend/app/components/report/Trade.vue

35 lines
1.5 KiB
Vue
Raw Normal View History

<script setup lang="ts">
import type { TradeReport, VillageRef } from '~/types/game'
const props = defineProps<{ report: TradeReport; worldId: number }>()
const mapLink = (v: VillageRef) => ({ path: `/map/${props.worldId}`, query: { x: v.x, y: v.y } })
</script>
<!-- A delivery: from where to where, as part of an offer or not, and the cargo per resource. -->
<template>
<div class="space-y-3 text-sm">
<p>{{ $t(report.offer ? 'reports.trade.arrived_offer' : 'reports.trade.arrived', { to: villageLabel(report.to) }) }}</p>
<table class="grid-table w-auto">
<tbody>
<tr v-for="side in (['from', 'to'] as const)" :key="side">
<th class="w-28">{{ $t(`reports.trade.${side}`) }}</th>
<td>
<NuxtLink :to="mapLink(report[side])" class="font-semibold hover:underline">{{ villageLabel(report[side]) }}</NuxtLink>
<span class="text-ink-500"> {{ report[side].player?.name ?? $t('common.barbarian') }}</span>
</td>
</tr>
<tr>
<th>{{ $t('reports.trade.cargo') }}</th>
<td>
<span class="flex flex-wrap gap-x-4 gap-y-0.5 tabular-nums">
<span v-for="r in (['wood', 'clay', 'iron'] as const)" :key="r" class="inline-flex items-center gap-1" :title="$t(`resources.${r}`)">
<IconResource :resource="r" class="size-4" />{{ report.cargo[r] }}
</span>
</span>
</td>
</tr>
</tbody>
</table>
</div>
</template>