imp: show duration text
This commit is contained in:
parent
436a5cc3a1
commit
ff621bd67c
@ -12,6 +12,19 @@ function calculateValue(value: any) {
|
|||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
return (value[0] && value[0].amount) || '-';
|
return (value[0] && value[0].amount) || '-';
|
||||||
}
|
}
|
||||||
|
if(String(value).search(/^\d+s$/g) > -1) {
|
||||||
|
const duration = Number(value.replace(/s/, ''))
|
||||||
|
if(duration > 24*60*60) {
|
||||||
|
return `${duration / ( 24 * 60 * 60)} days`
|
||||||
|
}
|
||||||
|
if(duration > 60*60) {
|
||||||
|
return `${duration / (60 * 60)} hours`
|
||||||
|
}
|
||||||
|
if(duration > 60) {
|
||||||
|
return `${duration / 60} mins`
|
||||||
|
}
|
||||||
|
return duration
|
||||||
|
}
|
||||||
const newValue = Number(value);
|
const newValue = Number(value);
|
||||||
if (`${newValue}` === 'NaN' || typeof value === 'boolean') {
|
if (`${newValue}` === 'NaN' || typeof value === 'boolean') {
|
||||||
return value;
|
return value;
|
||||||
@ -22,6 +35,11 @@ function calculateValue(value: any) {
|
|||||||
}
|
}
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatTitle(v: string) {
|
||||||
|
if(!v) return ""
|
||||||
|
return v.replace(/_/g, " ")
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
@ -37,7 +55,7 @@ function calculateValue(value: any) {
|
|||||||
:key="index"
|
:key="index"
|
||||||
class="rounded-sm bg-active px-4 py-2"
|
class="rounded-sm bg-active px-4 py-2"
|
||||||
>
|
>
|
||||||
<div class="text-xs mb-2 text-secondary">{{ item?.subtitle }}</div>
|
<div class="text-xs mb-2 text-secondary capitalize">{{ formatTitle(item?.subtitle) }}</div>
|
||||||
<div class="text-base text-main">{{ calculateValue(item?.value) }}</div>
|
<div class="text-base text-main">{{ calculateValue(item?.value) }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user