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 = { match: { label: 'Совпадение', color: 'green' }, uncertain: { label: 'Неопределённо', color: 'orange' }, no_match: { label: 'Нет совпадения', color: 'red' }, } export const cvProfileMeta: Record = { facade: { label: 'Фасад', color: 'blue' }, monument: { label: 'Памятник', color: 'purple' }, repetitive: { label: 'Повторяющийся объект', color: 'cyan' }, } export const setStatusMeta: Record = { 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, }))