2023-04-26 16:18:13 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import type { PropType } from 'vue';
|
2023-04-28 14:00:15 +00:00
|
|
|
import { useFormatter } from "@/stores";
|
2023-04-26 16:18:13 +00:00
|
|
|
const props = defineProps({
|
2023-04-27 11:00:44 +00:00
|
|
|
cardItem: {
|
|
|
|
type: Object as PropType<{ title: string; items: Array<any> }>,
|
|
|
|
},
|
|
|
|
});
|
2023-04-28 14:00:15 +00:00
|
|
|
|
|
|
|
const formatter = useFormatter()
|
|
|
|
function calculateValue(value: any){
|
|
|
|
if (Array.isArray(value) ){
|
|
|
|
return (value[0] && value[0].amount)|| '-'
|
|
|
|
}
|
|
|
|
const newValue = Number(value)
|
|
|
|
if(`${newValue}` === 'NaN' || typeof(value) === 'boolean'){
|
|
|
|
return value
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newValue < 1 && newValue > 0) {
|
|
|
|
return formatter.formatDecimalToPercent(value)
|
|
|
|
}
|
|
|
|
return newValue
|
|
|
|
}
|
2023-04-26 16:18:13 +00:00
|
|
|
</script>
|
|
|
|
<template>
|
2023-04-27 11:00:44 +00:00
|
|
|
<div
|
2023-05-05 00:37:12 +00:00
|
|
|
class="bg-base-100 px-4 pt-3 pb-4 rounded mt-5"
|
2023-04-27 11:00:44 +00:00
|
|
|
v-if="props.cardItem?.items && props.cardItem?.items?.length > 0"
|
|
|
|
>
|
|
|
|
<div class="text-base mb-3 text-main">{{ props.cardItem?.title }}</div>
|
|
|
|
<div
|
|
|
|
class="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 2xl:grid-cols-6 gap-4"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
v-for="(item, index) of props.cardItem?.items"
|
|
|
|
:key="index"
|
|
|
|
class="rounded-sm bg-active px-4 py-2"
|
|
|
|
>
|
|
|
|
<div class="text-xs mb-2 text-secondary">{{ item?.subtitle }}</div>
|
2023-04-28 14:00:15 +00:00
|
|
|
<div class="text-base text-main">{{ calculateValue(item?.value) }}</div>
|
2023-04-27 11:00:44 +00:00
|
|
|
</div>
|
2023-04-27 07:34:39 +00:00
|
|
|
</div>
|
2023-04-27 11:00:44 +00:00
|
|
|
</div>
|
|
|
|
</template>
|