import { AppIconName } from '../../../../shared/ui/icon/icon-registry';

export type AdminDashboardCardStatus = 'loading' | 'ready' | 'empty' | 'error' | 'pending-backend';

export interface AdminDashboardCardState<T> {
  status: AdminDashboardCardStatus;
  value: T | null;
}

/**
 * Target metrics per PHASE-9-TENANT-REGISTRY-DOMAINS-CONTRACT.md §7's
 * marketplace dashboard list. All new fields optional - no contract doc
 * defines /api/admin/v2/dashboard/metrics's exact response shape yet
 * (FRONTEND-API-SURFACE-COMPLETE.md §15), so a field's absence must render
 * as "not available", never a fabricated 0.
 */
export interface AdminDashboardMetrics {
  categoriesCount: number;
  productsCount: number;
  gmvMinor?: number;
  currency?: string;
  paidOrdersCount?: number;
  conversionRate?: number;
  paymentFailureRate?: number;
  moderationQueueCount?: number;
  lowStockCount?: number;
  unmatchedEventsCount?: number;
  integrationHealthyCount?: number;
  integrationTotalCount?: number;
}

export type AdminDashboardQuickActionId =
  | 'edit-project'
  | 'categories'
  | 'products'
  | 'static-pages'
  | 'transactions'
  | 'orders'
  | 'media-library'
  | 'users'
  | 'monitoring'
  | 'analytics'
  | 'preview-marketplace'
  | 'add-product'
  | 'create-category'
  | 'edit-homepage';

export interface AdminDashboardQuickAction {
  id: AdminDashboardQuickActionId;
  icon: AppIconName;
  labelKey: string;
  descriptionKey: string;
  route: string[];
  external?: boolean;
}

export type AdminDashboardActivityType = 'draft-saved' | 'published';

export interface AdminDashboardActivityEntry {
  id: string;
  type: AdminDashboardActivityType;
  timestamp: number;
}

/** Kept exactly as-is: AdminMonitoringPageComponent also reads AdminDashboardFacade.healthChecks() and depends on this boolean shape. */
export interface AdminDashboardHealthCheck {
  code: string;
  labelKey: string;
  healthy: boolean;
}

/**
 * healthy: green check. attention: amber, informational (e.g. a draft exists) - not a defect.
 * unhealthy: red, a real validation problem. unknown: this sprint has no data source for the
 * check yet (never fabricated) - shown honestly rather than guessed.
 */
export type AdminDashboardHealthStatus = 'healthy' | 'attention' | 'unhealthy' | 'unknown' | 'loading';

/** Richer status rows for the redesigned dashboard homepage (Sprint 2) - separate from AdminDashboardHealthCheck above so Monitoring's existing boolean-badge usage stays untouched. */
export interface AdminDashboardHomeHealthCheck {
  code: string;
  labelKey: string;
  status: AdminDashboardHealthStatus;
  /** Set for metric-style rows (e.g. product count) rendered as a number instead of a pass/fail statement. */
  displayValue?: string | null;
}

export interface AdminDashboardDraftField {
  key: string;
  labelKey: string;
}

export interface AdminDashboardShortcut {
  id: string;
  icon: AppIconName;
  labelKey: string;
  route: string[];
  comingSoon?: boolean;
}
