<template>
    <TableComponent :loading="namespaces == null" v-for="namespaces in [repo.get().value]">
        <div class="resource-container namespace-container">
        <div class="header">
            <p>Name</p>
            <p>Age</p>
        </div>
        <NamespaceComponent :namespace="namespace" v-for="(namespace, index) in namespaces" class="resource" :class="{ even: index % 2 }"></NamespaceComponent>
    </div>
    </TableComponent>
</template>

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

const repo = ResourceRepo.init<Namespace>();
onMounted(() => {
    repo.listen("namespaces");    
});
onUnmounted(() => {
    repo.clear();
});
</script>

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