<template>
    <div>
        <p class="grid-element" @click="() => show = true">{{ configMap.metadata.name }}</p>
        <p class="grid-element">{{ configMap.metadata.namespace }}</p>
        <p class="grid-element">{{ calcAge(configMap.metadata.creationTimestamp) }}</p>
        <p class="grid-element"><span v-if="configMap.data">{{ Object.keys(configMap.data).length }}</span><span v-else>-</span></p>
        <ConfigmapViewComponent v-if="show" :config-map="configMap" @close="show = false"></ConfigmapViewComponent>
    </div>
</template>

<script setup lang="ts">
import type { ConfigMap } from '~/classes/ConfigMap';
import { calcAge } from '~/classes/Pod';
import ConfigmapViewComponent from './view/ConfigmapViewComponent.vue';

const show = ref(false);

defineProps<{
    configMap: ConfigMap
}>();
</script>