<script setup>
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import CardDescriptor from 'components/ui/CardDescriptor.vue';
import VnLv from 'components/ui/VnLv.vue';

const props = defineProps({
    id: {
        type: Number,
        required: false,
        default: null,
    },
});

const { t } = useI18n();
const route = useRoute();
const entityId = computed(() => props.id || route.params.id);

const filter = {
    fields: ['id', 'sectorFk', 'code', 'pickingOrder', 'row', 'column'],
    include: [{ relation: 'sector', scope: { fields: ['id', 'description'] } }],
};
</script>
<template>
    <CardDescriptor
        module="Parking"
        data-key="Parking"
        :url="`Parkings/${entityId}`"
        title="code"
        :filter="filter"
    >
        <template #body="{ entity }">
            <VnLv :label="t('globals.code')" :value="entity.code" />
            <VnLv :label="t('parking.pickingOrder')" :value="entity.pickingOrder" />
            <VnLv :label="t('parking.sector')" :value="entity.sector?.description" />
        </template>
    </CardDescriptor>
</template>
