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

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

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

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

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