<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";

const repo = ResourceRepo.init<CustomResourceDefinition>();
onMounted(() => {
    repo.listen("custom-resource-definitions");
});
onUnmounted(() => {
    repo.clear();
});
</script>

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