<template>
    <TableComponent :loading="persistentVolumeClaims == null" v-for="persistentVolumeClaims in [repo.get().value]">
        <div class="resource-container persistent-volume-claim-container">
            <div class="header">
                <p>Name</p>
                <p>Namespace</p>
                <p>Age</p>
                <p>Storage Class</p>
                <p>Access Modes</p>
            </div>
            <PersistentVolumeClaimComponent v-for="(persistentVolumeClaim, index) in persistentVolumeClaims" :persistent-volume-claim="persistentVolumeClaim" class="resource" :class="{ even: index % 2 }"></PersistentVolumeClaimComponent>
        </div>
    </TableComponent>
</template>

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

const repo = ResourceRepo.init<PersistentVolumeClaim>();

onMounted(() => {
    repo.listen("pvcs");
});
onUnmounted(() => {
    repo.clear();
});
</script>

<style scoped>
.persistent-volume-claim-container {
    display: grid;
    grid-template-columns: auto auto auto auto 1fr;
}
</style>