init
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import dayjs from 'dayjs'
|
||||
import utc from 'dayjs/plugin/utc'
|
||||
import type { CvProfile, SetStatus, Verdict } from '@/api/types'
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
/** Бэкенд хранит время в UTC без зоны — форматируем как UTC. */
|
||||
export function formatUtc(iso: string | null | undefined): string {
|
||||
if (!iso) return '—'
|
||||
const d = dayjs.utc(iso)
|
||||
return d.isValid() ? d.format('DD.MM.YYYY HH:mm:ss') : iso
|
||||
}
|
||||
|
||||
export function formatConfidence(confidence: number | null | undefined): string {
|
||||
if (confidence == null) return '—'
|
||||
return confidence.toFixed(2)
|
||||
}
|
||||
|
||||
export const verdictMeta: Record<Verdict, { label: string; color: string }> = {
|
||||
match: { label: 'Совпадение', color: 'green' },
|
||||
uncertain: { label: 'Неопределённо', color: 'orange' },
|
||||
no_match: { label: 'Нет совпадения', color: 'red' },
|
||||
}
|
||||
|
||||
export const cvProfileMeta: Record<CvProfile, { label: string; color: string }> = {
|
||||
facade: { label: 'Фасад', color: 'blue' },
|
||||
monument: { label: 'Памятник', color: 'purple' },
|
||||
repetitive: { label: 'Повторяющийся объект', color: 'cyan' },
|
||||
}
|
||||
|
||||
export const setStatusMeta: Record<SetStatus, { label: string; color: string }> = {
|
||||
DRAFT: { label: 'Черновик', color: 'default' },
|
||||
ACTIVE: { label: 'Активен', color: 'green' },
|
||||
ARCHIVED: { label: 'В архиве', color: 'default' },
|
||||
}
|
||||
|
||||
export const cvProfileOptions = (Object.keys(cvProfileMeta) as CvProfile[]).map((value) => ({
|
||||
value,
|
||||
label: cvProfileMeta[value].label,
|
||||
}))
|
||||
Reference in New Issue
Block a user