/**
 * Mock-детали тенанта для AdminTenantDetailView. На API: GET /api/admin/tenants/{code}
 * + GET /api/admin/tenants/{code}/balance-history + /users + /projects.
 *
 * Соответствует schema v8.7 §3 (tenants) + §4 (users) + §5 (projects) +
 * §4.4 (balance_transactions) + §10.2 (activity_log).
 */
import type { AdminTenant } from './mockTenants';

export interface TenantUser {
    id: number;
    email: string;
    fullName: string;
    role: 'admin' | 'manager' | 'reader';
    last_active_at: string;
    is_active: boolean;
}

export interface TenantProject {
    id: number;
    name: string;
    slug: string;
    suppliers: number;
    leadsToday: number;
    desiredToday: number;
    is_active: boolean;
}

export interface TenantBalanceTx {
    id: string; // 'TX-2026-0509-00347'
    type: 'topup' | 'lead_charge' | 'refund' | 'tariff_charge' | 'manual_adjustment';
    amount: number; // signed (+ topup, − charge)
    description: string;
    created_at: string; // ISO date
}

export interface TenantActivityEvent {
    id: number;
    event: string; // 'login_success' | 'deal.created' | 'webhook.received' | 'tariff.changed'
    actor: string; // email or 'system'
    summary: string;
    created_at: string;
}

export interface AdminTenantDetail extends AdminTenant {
    contact_email: string;
    contact_phone: string;
    legal_address: string;
    created_at: string;
    users: TenantUser[];
    projects: TenantProject[];
    balanceHistory: TenantBalanceTx[];
    activity: TenantActivityEvent[];
    leadsThisMonth: number;
    leadsThisWeek: number;
    avgLeadCost: number;
    runwayDays: number; // balance / avgDailySpend
}
