Files
portal/app/resources/js/composables/mockDealEvents.ts
T

93 lines
3.0 KiB
TypeScript
Raw Normal View History

/**
* Mock activity-events для DealDetailDrawer timeline.
*
* На API будет `GET /api/deals/{id}/events` — выборка из `activity_log` по
* tenant_id (RLS) + deal_id. По схеме v8.7 §10.2 (activity_log table).
*
* Типы событий — соответствуют ActivityLog event-константам:
* `deal.created`, `deal.status_changed`, `deal.viewed`, `deal.commented`,
* `deal.assigned`, `deal.balance_charged` и т.п.
*/
export interface DealEvent {
id: number;
type:
| 'deal.created'
| 'deal.status_changed'
| 'deal.viewed'
| 'deal.commented'
| 'deal.assigned'
| 'deal.balance_charged';
actor: { initials: string; name: string } | null; // null = system
minutesAgo: number;
detail: string;
}
export const MOCK_EVENTS: DealEvent[] = [
{
id: 1,
type: 'deal.created',
actor: null,
minutesAgo: 28,
detail: 'Лид принят с источника Я.Директ → landing-1',
},
{
id: 2,
type: 'deal.balance_charged',
actor: null,
minutesAgo: 28,
detail: 'Списано 1 лид с баланса (стоимость 1 850 ₽)',
},
{
id: 3,
type: 'deal.assigned',
actor: { initials: 'СА', name: 'Система автораспределения' },
minutesAgo: 27,
detail: 'Назначен менеджер: Иван П.',
},
{
id: 4,
type: 'deal.viewed',
actor: { initials: 'ИП', name: 'Иван П.' },
minutesAgo: 18,
detail: 'Менеджер открыл карточку',
},
{
id: 5,
type: 'deal.status_changed',
actor: { initials: 'ИП', name: 'Иван П.' },
minutesAgo: 12,
detail: 'Новые → Просмотрено',
},
{
id: 6,
type: 'deal.commented',
actor: { initials: 'ИП', name: 'Иван П.' },
minutesAgo: 8,
detail: 'Дозвонился, заинтересована — перезвоню после 14:00',
},
];
export function eventTypeLabel(type: DealEvent['type']): string {
const map: Record<DealEvent['type'], string> = {
'deal.created': 'Создана',
'deal.status_changed': 'Смена статуса',
'deal.viewed': 'Просмотр',
'deal.commented': 'Комментарий',
'deal.assigned': 'Назначение',
'deal.balance_charged': 'Списание',
};
return map[type];
}
export function eventTypeIcon(type: DealEvent['type']): string {
const map: Record<DealEvent['type'], string> = {
'deal.created': 'mdi-plus-circle-outline',
'deal.status_changed': 'mdi-swap-horizontal',
'deal.viewed': 'mdi-eye-outline',
'deal.commented': 'mdi-comment-outline',
'deal.assigned': 'mdi-account-arrow-right-outline',
'deal.balance_charged': 'mdi-currency-rub',
};
return map[type];
}