home-cert-assistant/frontend/src/components/CountryListItem.vue
Magnus Leßmann (MarkL4YG) 0e60183372
Some checks failed
Build / build (pull_request) Successful in 39s
Check formatting / check-formatting (pull_request) Failing after 16s
fix: Selection not working in country autocomplete
2025-07-12 15:16:04 +02:00

44 lines
1 KiB
Vue

<script setup lang="ts">
// Define props with proper TypeScript typing
import { computed } from "vue";
import type { CountryListItemType } from "@/utils/countries.ts";
type ListItem<T> = {
raw: T;
}
// Define props with proper TypeScript typing
const props = defineProps<{
item: ListItem<CountryListItemType>;
itemProps?: Record<string, unknown>;
}>();
// Helper functions to check the type of the item
const isDivider = computed(() => {
return "divider" in props.item.raw && props.item.raw.divider;
});
const headerText = computed(() => {
return "header" in props.item.raw ? props.item.raw.header : "";
});
const countryItem = computed(() => {
return !isDivider.value && !headerText.value && "country" in props.item.raw ? props.item.raw : undefined;
});
</script>
<template>
<v-divider
v-if="isDivider"
class="my-2"
/>
<v-list-subheader v-if="headerText">
{{ headerText }}
</v-list-subheader>
<v-list-item
v-if="countryItem"
v-bind="itemProps"
:title="countryItem.country"
/>
</template>