import { UserData } from "../UserTable";

export interface LoginHistoryEntry {
  id: string;
  ipAddress: string;
  country: string | null;
  city: string | null;
  timestamp: string;
  logoutAt: string | null;
  userAgent: string | null;
  provider: string;
  success: boolean;
}

export interface AdminNote {
  id: string;
  category:
    | "general"
    | "support"
    | "billing"
    | "security"
    | "compliance"
    | "technical"
    | "sales";
  content: string;
  createdBy: string;
  createdAt: string;
}

export interface BillingEmail {
  id: string;
  subject: string;
  sentAt: string;
  status: "sent" | "failed" | "paid" | "overdue";
  amount?: number;
}

export interface StripeInvoice {
  id: string;
  type: "stripe_invoice";
  number: string | null;
  status: string;
  amount: number;
  currency: string;
  description: string;
  createdAt: string;
  paidAt: string | null;
  hostedInvoiceUrl: string | null;
  invoicePdf: string | null;
  billingReason: string | null;
  periodStart: string | null;
  periodEnd: string | null;
}

export interface InvoiceSummary {
  totalPaid: number;
  totalInvoices: number;
  paidInvoices: number;
  openInvoices: number;
  failedPayments: number;
}

export interface UserLink {
  id: string;
  linkType:
    | "KNOWLEDGE_BASE"
    | "AI_AGENT"
    | "AI_VOICE_AGENT"
    | "WHATSAPP_INTEGRATION"
    | "DASHBOARD"
    | "DOCUMENTATION"
    | "SUPPORT"
    | "APPOINTMENTS"
    | "CUSTOMERS"
    | "WAITLISTS"
    | "ANALYTICS"
    | "BILLING"
    | "SETTINGS"
    | "CALENDAR"
    | "REPORTS"
    | "CUSTOM";
  title: string;
  url: string;
  description: string | null;
  icon: string | null;
  isActive: boolean;
  sortOrder: number;
  createdAt: string;
}

export interface IntegrationsState {
  n8nWebhookToken: string;
  voiceAgentId: string;
  voiceAgentConfig: Record<string, string>;
}

export interface LinkFormState {
  linkType: UserLink["linkType"];
  title: string;
  url: string;
  description: string;
}

export interface UserModalProps {
  user: UserData | null;
  onClose: () => void;
  onSave?: (userId: string, updates: Record<string, unknown>) => void;
  onSuspend?: (userId: string, reason: string) => void;
  onActivate?: (userId: string) => void;
  isAdmin: boolean;
}

export type TabType =
  | "overview"
  | "history"
  | "notes"
  | "billing"
  | "links"
  | "integrations"
  | "actions";

// Shared constants
export const CURRENCY_OPTIONS = [
  { value: "GBP", label: "£ GBP", symbol: "£" },
  { value: "USD", label: "$ USD", symbol: "$" },
  { value: "EUR", label: "€ EUR", symbol: "€" },
  { value: "AED", label: "AED", symbol: "AED " },
  { value: "SAR", label: "SAR", symbol: "SAR " },
  { value: "QAR", label: "QAR", symbol: "QAR " },
];

export const LINK_TYPE_OPTIONS = [
  { value: "KNOWLEDGE_BASE", label: "Knowledge Base", icon: "📚" },
  { value: "AI_AGENT", label: "AI Agent", icon: "🤖" },
  { value: "AI_VOICE_AGENT", label: "AI Voice Agent", icon: "🎙️" },
  { value: "WHATSAPP_INTEGRATION", label: "WhatsApp", icon: "💬" },
  { value: "APPOINTMENTS", label: "Appointments", icon: "📅" },
  { value: "CUSTOMERS", label: "Customers", icon: "👥" },
  { value: "WAITLISTS", label: "Waitlists", icon: "⏳" },
  { value: "CALENDAR", label: "Calendar", icon: "🗓️" },
  { value: "ANALYTICS", label: "Analytics", icon: "📈" },
  { value: "REPORTS", label: "Reports", icon: "📋" },
  { value: "BILLING", label: "Billing", icon: "💳" },
  { value: "DASHBOARD", label: "Dashboard", icon: "📊" },
  { value: "DOCUMENTATION", label: "Documentation", icon: "📄" },
  { value: "SETTINGS", label: "Settings", icon: "⚙️" },
  { value: "SUPPORT", label: "Support", icon: "🆘" },
  { value: "CUSTOM", label: "Custom", icon: "🔗" },
];

// Re-export UserData for convenience
export type { UserData };
