Files
vps-tracker/apps/web/src/lib/vps-sync-fields.ts
T
DenozordecandCursor baa13260c6
Docker / build (push) Has been cancelled
feat(web, db): autocomplete проекта VPS, защита полей при синке и стиль Command
Проект выбирается из справочника; ручные правки автоматически попадают в userOverrides без сброса при сохранении. CommandDialog приведён к эталону shadcn/ReUI.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 22:22:21 +07:00

31 lines
1.2 KiB
TypeScript

/** Поля VPS, которые BILLmanager-синк может перезаписывать (см. sync.ts). */
export const VPS_SYNC_OVERRIDE_FIELDS = [
{ key: 'country', label: 'Страна' },
{ key: 'city', label: 'Город' },
{ key: 'datacenter', label: 'Дата-центр' },
{ key: 'os', label: 'ОС' },
{ key: 'project', label: 'Проект' },
{ key: 'notes', label: 'Заметки' },
{ key: 'status', label: 'Статус' },
{ key: 'tariffType', label: 'Тип тарифа' },
{ key: 'currency', label: 'Валюта' },
{ key: 'dailyRate', label: 'Ставка/день' },
{ key: 'monthlyRate', label: 'Ставка/мес' },
{ key: 'paidUntil', label: 'Оплачено до' },
] as const
export type VpsSyncOverrideField = (typeof VPS_SYNC_OVERRIDE_FIELDS)[number]['key']
export function parseUserOverrides(raw: unknown): string[] {
if (Array.isArray(raw)) return raw.filter((x) => typeof x === 'string')
if (typeof raw === 'string' && raw.trim()) {
try {
const parsed = JSON.parse(raw) as unknown
if (Array.isArray(parsed)) return parsed.filter((x) => typeof x === 'string')
} catch {
return []
}
}
return []
}