import { api } from './api'

export interface BriefingUser {
  id: string
  name: string
  email: string
  role: string
}

export interface CompanyHealth {
  status: string
  revenue_ytd: number
  expenses_ytd: number
  profit_margin: number
  cash_position: number
  active_deals: number
  total_pipeline: number
}

export interface RealTask {
  id: string
  title: string
  priority: string
  status: string
  days_open: number
  category: string
}

export interface RealDeal {
  id: string
  name: string
  customer: string
  value: number
  currency: string
  stage: string
  probability: number
  days_in_stage: number
}

export interface TeamMember {
  name: string
  role: string
  department: string
  status: string
  open_tasks: number
}

export interface TeamOverview {
  total_members: number
  active_now: number
  on_leave: number
  open_tickets: number
  high_priority: number
  members: TeamMember[]
}

export interface AccountSummary {
  code: string
  name: string
  type: string
  amount: number
}

export interface FinancialStatus {
  total_assets: number
  total_liabilities: number
  equity: number
  monthly_burn: number
  runway_months: number
  top_accounts: AccountSummary[]
}

export interface RealAlert {
  level: string
  title: string
  description: string
  source: string
  action_url?: string
}

export interface RecommendedAction {
  priority: number
  title: string
  description: string
  impact: string
  time_estimate: string
  related_ids: string[]
}

export interface RealDailyBriefing {
  user: BriefingUser
  generated_at: string
  company_health: CompanyHealth
  my_tasks: RealTask[]
  my_deals: RealDeal[]
  team_overview: TeamOverview
  financial_status: FinancialStatus
  alerts: RealAlert[]
  actions: RecommendedAction[]
}

export const briefingApi = {
  getRealBriefing: () => api.get<RealDailyBriefing>('/briefing/real'),
}
