2022-09-03 09:17:57 +00:00
|
|
|
<template>
|
|
|
|
<NuxtLink
|
|
|
|
ref="card"
|
|
|
|
:to="`/location/${location.id}`"
|
2022-12-30 01:19:15 +00:00
|
|
|
class="card bg-base-100 text-base-content rounded-md transition duration-300 shadow-md"
|
2022-09-03 09:17:57 +00:00
|
|
|
>
|
2022-09-06 18:32:13 +00:00
|
|
|
<div
|
|
|
|
class="card-body"
|
|
|
|
:class="{
|
|
|
|
'p-4': !dense,
|
|
|
|
'py-2 px-3': dense,
|
|
|
|
}"
|
|
|
|
>
|
2022-12-30 01:19:15 +00:00
|
|
|
<h2 class="flex items-center justify-between gap-2">
|
2022-09-03 09:17:57 +00:00
|
|
|
<label class="swap swap-rotate" :class="isActive ? 'swap-active' : ''">
|
2024-03-01 01:20:18 +00:00
|
|
|
<MdiArrowRight class="swap-on h-6 w-6" />
|
|
|
|
<MdiMapMarkerOutline class="swap-off h-6 w-6" />
|
2022-09-03 09:17:57 +00:00
|
|
|
</label>
|
2022-12-30 01:19:15 +00:00
|
|
|
<span class="mx-auto">
|
|
|
|
{{ location.name }}
|
|
|
|
</span>
|
2024-03-01 01:20:18 +00:00
|
|
|
<span class="badge badge-primary h-6 badge-lg" :class="{ 'opacity-0': !hasCount }">
|
2022-12-30 05:18:49 +00:00
|
|
|
{{ count }}
|
|
|
|
</span>
|
2022-09-03 09:17:57 +00:00
|
|
|
</h2>
|
|
|
|
</div>
|
|
|
|
</NuxtLink>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2024-03-01 17:21:45 +00:00
|
|
|
import type { LocationOut, LocationOutCount, LocationSummary } from "~~/lib/api/types/data-contracts";
|
2024-03-01 01:20:18 +00:00
|
|
|
import MdiArrowRight from "~icons/mdi/arrow-right";
|
|
|
|
import MdiMapMarkerOutline from "~icons/mdi/map-marker-outline";
|
2022-09-03 09:17:57 +00:00
|
|
|
|
2022-10-24 04:54:39 +00:00
|
|
|
const props = defineProps({
|
2022-09-03 09:17:57 +00:00
|
|
|
location: {
|
2022-10-24 04:54:39 +00:00
|
|
|
type: Object as () => LocationOutCount | LocationOut | LocationSummary,
|
2022-09-03 09:17:57 +00:00
|
|
|
required: true,
|
|
|
|
},
|
2022-09-06 18:32:13 +00:00
|
|
|
dense: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2022-09-03 09:17:57 +00:00
|
|
|
});
|
|
|
|
|
2022-10-24 04:54:39 +00:00
|
|
|
const hasCount = computed(() => {
|
|
|
|
return !!(props.location as LocationOutCount).itemCount;
|
|
|
|
});
|
|
|
|
|
|
|
|
const count = computed(() => {
|
|
|
|
if (hasCount.value) {
|
|
|
|
return (props.location as LocationOutCount).itemCount;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-09-03 09:17:57 +00:00
|
|
|
const card = ref(null);
|
|
|
|
const isHover = useElementHover(card);
|
|
|
|
const { focused } = useFocus(card);
|
|
|
|
|
|
|
|
const isActive = computed(() => isHover.value || focused.value);
|
|
|
|
</script>
|