<script setup>
import { computed } from 'vue';
import { useRoute } from 'vue-router';
import VnCard from 'components/common/VnCard.vue';
import OrderDescriptor from 'pages/Order/Card/OrderDescriptor.vue';
import OrderFilter from './OrderFilter.vue';
import OrderSearchbar from './OrderSearchbar.vue';
import OrderCatalogFilter from './OrderCatalogFilter.vue';
const config = {
    OrderCatalog: OrderCatalogFilter,
};
const route = useRoute();

const routeName = computed(() => route.name);
const customRouteRedirectName = computed(() => {
    const route = config[routeName.value];
    if (route) return null;
    return 'OrderList';
});
const customFilterPanel = computed(() => {
    const filterPanel = config[routeName.value] ?? OrderFilter;
    return filterPanel;
});
</script>

<template>
    <VnCard
        data-key="Order"
        base-url="Orders"
        :descriptor="OrderDescriptor"
        :filter-panel="customFilterPanel"
        :search-data-key="customRouteRedirectName"
    >
        <template #searchbar>
            <OrderSearchbar />
        </template>
    </VnCard>
</template>
