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

50 lines
2.2 KiB
TypeScript

/**
* Mock-данные для ReportsView.
*
* На API будет:
* POST /api/reports — создать отчёт (job).
* GET /api/reports — список (`reports` table из schema v8.7).
* GET /api/reports/{id}/file — скачать готовый файл (S3-presigned).
* POST /api/reports/{id}/retry — retry-failed (CTO-6: 3 попытки / 7 дней / только owner).
*
* Соответствует ТЗ §6.6 + CTO-6/CTO-7 (квота 3 одновременных).
*/
export type ReportType = 'deals' | 'managers' | 'sources' | 'billing';
export type ReportFormat = 'csv' | 'xlsx' | 'json' | 'pdf';
export type ReportStatus = 'queued' | 'running' | 'done' | 'failed';
export interface ReportTypeOption {
id: ReportType;
name: string;
description: string;
}
export const REPORT_TYPES: ReportTypeOption[] = [
{ id: 'deals', name: 'Сделки · детально', description: 'все колонки, фильтры применены' },
{ id: 'managers', name: 'Менеджеры', description: 'конверсия, средний чек, время в воронке' },
{ id: 'sources', name: 'Источники', description: 'Я.Директ / VK / Avito / прямые' },
{ id: 'billing', name: 'Биллинг', description: 'пополнения, списания, возвраты' },
];
export const REPORT_FORMATS: { id: ReportFormat; label: string }[] = [
{ id: 'csv', label: 'CSV' },
{ id: 'xlsx', label: 'XLSX' },
{ id: 'json', label: 'JSON' },
{ id: 'pdf', label: 'PDF' },
];
export interface ReportJob {
id: number;
title: string;
format: ReportFormat;
status: ReportStatus;
sizeText: string | null; // '1.8 MB' / null
rowsText: string | null; // '412 строк' / null
timeText: string; // '14:21 → 14:23' / 'в работе · ~30 секунд' / 'позиция 1' / '2/3 попытки · ошибка S3 timeout · 12:14' / '6 дней назад'
progress: number | null; // 0..100 для running
attempt: number; // 1..3
error: string | null;
downloadUrl: string | null; // signed URL (24ч) скачивания готового файла; null для не-готовых
}