<script setup>
import { ref, onBeforeMount, useAttrs } from 'vue';
import VnSelect from 'src/components/common/VnSelect.vue';

const $props = defineProps({
    row: {
        type: [Object],
        default: null,
    },
    find: {
        type: String,
        default: null,
    },
});
const options = ref([]);
onBeforeMount(async () => {
    const { url } = useAttrs();
    const findBy = $props.find ?? url?.charAt(0)?.toLocaleLowerCase() + url?.slice(1, -1);
    if (findBy) options.value = [$props.row[findBy]];
});
</script>

<template>
    <VnSelect v-bind="$attrs" :options="$attrs.options ?? options" />
</template>
