<script setup>
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import { computed } from 'vue';

import VnCard from 'components/common/VnCard.vue';
import ZoneDescriptor from './ZoneDescriptor.vue';

const { t } = useI18n();
const route = useRoute();

const routeName = computed(() => route.name);
const customRouteRedirectName = computed(() => {
    if (routeName.value === 'ZoneLocations') return null;
    return routeName.value;
});
const searchBarDataKeys = {
    ZoneWarehouses: 'ZoneWarehouses',
    ZoneSummary: 'ZoneSummary',
    ZoneLocations: 'ZoneLocations',
    ZoneCalendar: 'ZoneCalendar',
};
</script>
<template>
    <VnCard
        data-key="Zone"
        :descriptor="ZoneDescriptor"
        :search-data-key="searchBarDataKeys[routeName]"
        :search-custom-route-redirect="customRouteRedirectName"
        :search-redirect="!!customRouteRedirectName"
        :searchbar-label="t('list.searchZone')"
        :searchbar-info="t('list.searchInfo')"
    />
</template>
