<template>
    <Component v-if="components[resource]" :is="components[resource]"></Component>
    <p v-else>Invalid resource</p>
</template>

<script setup lang="ts">
import PodList from '~/components/inspect/resources/PodList.vue';
import CustomResourceDefinitionList from '~/components/inspect/resources/CustomResourceDefinitionList.vue';
import IngressList from '~/components/inspect/resources/IngressList.vue';
import ServiceList from '~/components/inspect/resources/ServiceList.vue';
import DeploymentList from "~/components/inspect/resources/DeploymentList.vue";
import NodeList from '~/components/inspect/resources/NodeList.vue';
import SecretList from '~/components/inspect/resources/SecretList.vue';
import ConfigMapList from '~/components/inspect/resources/ConfigMapList.vue';
import StatefulSetList from '~/components/inspect/resources/StatefulSetList.vue';
import PersistentVolumeList from '~/components/inspect/resources/PersistentVolumeList.vue';
import PersistentVolumeClaimList from '~/components/inspect/resources/PersistentVolumeClaimList.vue';
import NamespaceList from '~/components/inspect/resources/NamespaceList.vue';
import type { Component } from "vue";
import {ResourceType} from "~/components/inspect/ResourceType";

const resource = useRoute().params.resource as ResourceType;

const components: Record<ResourceType, Component> = {
    [ResourceType.NODE]: NodeList,
    [ResourceType.NAMESPACE]: NamespaceList,
    [ResourceType.CUSTOM_RESOURCE_DEFINITION]: CustomResourceDefinitionList,

    [ResourceType.POD]: PodList,
    [ResourceType.DEPLOYMENT]: DeploymentList,
    [ResourceType.STATEFUL_SET]: StatefulSetList,

    [ResourceType.SERVICE]: ServiceList,
    [ResourceType.INGRESS]: IngressList,

    [ResourceType.SECRET]: SecretList,
    [ResourceType.CONFIG_MAP]: ConfigMapList,

    [ResourceType.PV]: PersistentVolumeList,
    [ResourceType.PVC]: PersistentVolumeClaimList,
};
</script>