homebox/frontend/components/Item/Card.vue

65 lines
2.1 KiB
Vue
Raw Normal View History

2022-09-03 01:17:57 -08:00
<template>
<NuxtLink
class="group card bg-neutral text-neutral-content hover:bg-primary transition-colors duration-300"
:to="`/item/${item.id}`"
>
2022-12-30 20:32:19 -09:00
<div class="card-body p-4 gap-3">
2022-09-03 01:17:57 -08:00
<h2 class="card-title">
{{ item.name }}
<Icon v-if="item.archived" class="ml-auto" name="mdi-archive-outline" />
2022-12-30 20:32:19 -09:00
<Icon v-else class="ml-auto" name="mdi-package-variant" />
2022-09-03 01:17:57 -08:00
</h2>
2022-12-30 20:32:19 -09:00
<div v-if="colOne" class="flex gap-x-2 items-center justify-between">
<NuxtLink
v-if="item.location"
class="badge badge-primary group-hover:badge-ghost"
:to="`/location/${item.location.id}`"
>
<Icon name="heroicons-map-pin" class="mr-2 swap-on"></Icon>
{{ item.location.name }}
</NuxtLink>
<div class="flex gap-2 ml-auto items-end">
<div v-if="item.purchasePrice" class="tooltip" data-tip="Purchase Price">
<span class="badge badge-ghost">
<Currency :amount="item.purchasePrice" />
</span>
</div>
<div v-if="item.insured" class="tooltip" data-tip="Insured">
<Icon class="h-5 w-5 text-base-200" name="mdi-shield-check" />
</div>
<div v-if="item.quantity > 1" class="tooltip" data-tip="Quantity">
<span class="badge badge-ghost">
{{ item.quantity }}
</span>
</div>
</div>
</div>
<span
class="w-[100%] group-hover:bg-neutral-content h-[3px] transition-colors duration-300 rounded-box bg-primary"
></span>
2022-09-03 01:17:57 -08:00
<div class="flex gap-2 flex-wrap justify-end">
2022-12-30 20:32:19 -09:00
<LabelChip v-for="label in top3" :key="label.id" :label="label" size="sm" />
2022-09-03 01:17:57 -08:00
</div>
</div>
</NuxtLink>
</template>
<script setup lang="ts">
import { ItemOut, ItemSummary } from "~~/lib/api/types/data-contracts";
2022-12-30 20:32:19 -09:00
const colOne = computed(() => {
return props.item.location || props.item.purchasePrice;
});
const top3 = computed(() => {
return props.item.labels.slice(0, 3) || [];
});
2022-09-03 01:17:57 -08:00
2022-09-06 10:32:13 -08:00
const props = defineProps({
2022-09-03 01:17:57 -08:00
item: {
type: Object as () => ItemOut | ItemSummary,
2022-09-03 01:17:57 -08:00
required: true,
},
});
</script>