<template>
    <TableComponent :loading="customResourceDefinitions == null" v-for="customResourceDefinitions in [repo.get().value]">
        <div class="resource-container crd-container">
            <div class="header">
                <p>Name</p>
                <p>Group</p>
            </div>
            <div v-for="(customResourceDefinition, index) in customResourceDefinitions" class="resource" :class="{ even: index % 2 }">
                <p class="grid-element">{{ customResourceDefinition.metadata.name }}</p>
                <p class="grid-element">{{ customResourceDefinition.spec.group }}</p>
            </div>
        </div>
    </TableComponent>
</template>

<script setup lang="ts">
import { ResourceRepo } from '~/classes/repo/ResourceRepo';
import type {CustomResourceDefinition} from "~/classes/CustomResourceDefinition";
import {ResourceType} from "~/classes/ResourceTypes";

const repo = ResourceRepo.init<CustomResourceDefinition>();
onMounted(() => {
    repo.listen(ResourceType.CUSTOM_RESOURCE_DEFINITION);
});
onUnmounted(() => {
    repo.clear();
});
</script>

<style scoped>
.crd-container {
    grid-template-columns: 1fr 1fr;
}
</style>