@@ -48,8 +48,9 @@ import UiCircleProgressBar, {
48
48
import UiInfo from '@core/components/ui/info/UiInfo.vue'
49
49
import UiTag from '@core/components/ui/tag/UiTag.vue'
50
50
import UiUserLink from '@core/components/ui/user-link/UiUserLink.vue'
51
+ import { useMapper } from '@core/composables/mapper.composable.ts'
51
52
import { vTooltip } from '@core/directives/tooltip.directive'
52
- import type { Message, Task } from '@core/types/task.type.ts'
53
+ import type { Message, Task, TaskStatus } from '@core/types/task.type.ts'
53
54
import { faCircleNotch } from '@fortawesome/free-solid-svg-icons'
54
55
import { useTimeAgo } from '@vueuse/core'
55
56
import { computed } from 'vue'
@@ -68,8 +69,8 @@ const timeAgo = useTimeAgo(taskTimeStatus, {
68
69
fullDateFormatter: (date: Date) => date.toLocaleDateString(),
69
70
messages: {
70
71
justNow: t('just-now'),
71
- past: n => (n.match(/\d/) ? t('ago', [n]) : n),
72
- future: n => (n.match(/\d/) ? t('in', [n]) : n),
72
+ past: (n: any) => (n.match(/\d/) ? t('ago', [n]) : n),
73
+ future: (n: any) => (n.match(/\d/) ? t('in', [n]) : n),
73
74
month: (n, past) =>
74
75
n === 1 ? (past ? t('last-month') : t('next-month')) : `${n} ${t(`month${n > 1 ? 's' : ''}`)}`,
75
76
year: (n, past) => (n === 1 ? (past ? t('last-year') : t('next-year')) : `${n} ${t(`year${n > 1 ? 's' : ''}`)}`),
@@ -91,7 +92,7 @@ const taskIsComplete = computed(() => {
91
92
92
93
const taskElapsedMessage = computed(() => {
93
94
if (!task.start && !task.end) {
94
- return ''
95
+ return
95
96
}
96
97
97
98
if (taskIsComplete.value) {
@@ -124,16 +125,16 @@ const getEffectiveStatus = computed<CircleProgressBarAccent>(() => {
124
125
const subtasks = task.subtasks || []
125
126
126
127
if (subtasks.length === 0) {
127
- switch (task.status) {
128
- case 'failure':
129
- return 'danger'
130
- case 'interrupted':
131
- return 'warning'
132
- case ' success':
133
- return 'info'
134
- default:
135
- return 'info'
136
- }
128
+ return useMapper<TaskStatus, CircleProgressBarAccent>(
129
+ () => task.status,
130
+ {
131
+ pending: 'warning',
132
+ interrupted: 'warning',
133
+ success: 'info',
134
+ failure: 'danger',
135
+ },
136
+ () => 'info'
137
+ ).value
137
138
}
138
139
139
140
const subStatuses = subtasks.map(evaluate)
0 commit comments