<template>
    <TableComponent :loading="configMaps == null" v-for="configMaps in [repo.get().value]">
        <div class="resource-container config-map-container">
            <div class="header">
                <p>Name</p>
                <p>Namespace</p>
                <p>Age</p>
                <p>Entries</p>
            </div>
            <ConfigMapComponent v-for="(configMap, index) in configMaps" :config-map="configMap" class="resource" :class="{ even: index % 2 }"></ConfigMapComponent>
        </div>
    </TableComponent>
</template>

<script setup lang="ts">
import type { ConfigMap } from '~/classes/ConfigMap';
import { ResourceRepo } from '~/classes/repo/ResourceRepo';
import ConfigMapComponent from '~/components/configmap/ConfigMapComponent.vue';

const repo = ResourceRepo.init<ConfigMap>();
onMounted(() => {
    repo.listen("config-maps");
});
onUnmounted(() => {
    repo.clear();
});
</script>

<style scoped>
.config-map-container {
    display: grid;
    grid-template-columns: auto auto auto 1fr;
}
</style>