44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
|
|
/**
|
|||
|
|
* Sprint 4 Phase B/1 (audit O-refactor-04 хвост): formatters для AdminTenantDetailView
|
|||
|
|
* + sub-components TenantDetailHeader / TenantDetailTabs.
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
export function formatRub(v: number): string {
|
|||
|
|
if (v === 0) return '0 ₽';
|
|||
|
|
const sign = v < 0 ? '−' : '';
|
|||
|
|
return sign + new Intl.NumberFormat('ru-RU').format(Math.abs(v)) + ' ₽';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export function formatDate(iso: string): string {
|
|||
|
|
return new Date(iso).toLocaleString('ru-RU', { dateStyle: 'short', timeStyle: 'short' });
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export function statusColor(s: string): string {
|
|||
|
|
if (s === 'active') return 'success';
|
|||
|
|
if (s === 'trial') return 'info';
|
|||
|
|
if (s === 'overdue') return 'warning';
|
|||
|
|
return 'error';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export function txTypeLabel(t: string): string {
|
|||
|
|
return (
|
|||
|
|
{
|
|||
|
|
topup: 'Пополнение',
|
|||
|
|
lead_charge: 'Списание за лид',
|
|||
|
|
refund: 'Возврат',
|
|||
|
|
tariff_charge: 'Списание тарифа',
|
|||
|
|
manual_adjustment: 'Ручная корректировка',
|
|||
|
|
}[t] ?? t
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export function txTypeColor(t: string, amount: number): string {
|
|||
|
|
if (amount > 0) return 'success';
|
|||
|
|
if (t === 'manual_adjustment') return 'warning';
|
|||
|
|
return 'error';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export function roleLabel(r: string): string {
|
|||
|
|
return { admin: 'Администратор', manager: 'Менеджер', reader: 'Читатель' }[r] ?? r;
|
|||
|
|
}
|