// Demo data for CallLog testing
export const demoCallLogs = [
  {
    Id: 1,
    HistoryID: "CALL001",
    CallID: "3CX-12345",
    Duration: "00:03:45",
    TimeStart: "2024-01-15T08:30:00Z",
    TimeAnswered: "2024-01-15T08:30:05Z",
    TimeEnd: "2024-01-15T08:33:50Z",
    ReasonTerminated: "Normal",
    FromNo: "0901234567",
    ToNo: "0987654321",
    FromDN: "ext101",
    ToDN: "ext102",
    DialNo: "0987654321",
    ReasonChanged: "",
    FinalNumber: "0987654321",
    FinalDN: "ext102",
    BillCode: "LOCAL",
    BillRate: 100.00,
    BillCost: 1500.00,
    BillName: "Local Rate",
    Chain: "ext101->ext102",
    FromType: "External",
    ToType: "Internal",
    FinalType: "Internal",
    FromDispName: "Nguyễn Văn A",
    ToDispName: "Trần Thị B",
    FinalDispName: "Trần Thị B",
    MissedQueueCalls: "",
    CallType: "Inbound",
    LeadStatus: 1,
    LeadStatusStr: "Tạo mới",
    StatusContent: "Khách hàng quan tâm sản phẩm",
    CreatedTime: "2024-01-15T08:30:00Z",
    UpdatedTime: "2024-01-15T08:35:00Z",
    CreatedBy: 1,
    CreatedByUserName: "admin",
    UpdatedBy: 1,
    UpdatedByUserName: "admin"
  },
  {
    Id: 2,
    HistoryID: "CALL002",
    CallID: "3CX-12346",
    Duration: "00:02:30",
    TimeStart: "2024-01-15T09:00:00Z",
    TimeAnswered: "2024-01-15T09:00:03Z",
    TimeEnd: "2024-01-15T09:02:33Z",
    ReasonTerminated: "Normal",
    FromNo: "0912345678",
    ToNo: "0987654321",
    FromDN: "ext103",
    ToDN: "ext102",
    DialNo: "0987654321",
    ReasonChanged: "",
    FinalNumber: "0987654321",
    FinalDN: "ext102",
    BillCode: "LOCAL",
    BillRate: 100.00,
    BillCost: 1000.00,
    BillName: "Local Rate",
    Chain: "ext103->ext102",
    FromType: "External",
    ToType: "Internal",
    FinalType: "Internal",
    FromDispName: "Lê Văn C",
    ToDispName: "Trần Thị B",
    FinalDispName: "Trần Thị B",
    MissedQueueCalls: "",
    CallType: "Inbound",
    LeadStatus: 2,
    LeadStatusStr: "Đã tiếp nhận",
    StatusContent: "Khách hàng hỏi về giá cả",
    CreatedTime: "2024-01-15T09:00:00Z",
    UpdatedTime: "2024-01-15T09:05:00Z",
    CreatedBy: 1,
    CreatedByUserName: "admin",
    UpdatedBy: 1,
    UpdatedByUserName: "admin"
  },
  {
    Id: 3,
    HistoryID: "CALL003",
    CallID: "3CX-12347",
    Duration: "00:05:15",
    TimeStart: "2024-01-15T10:15:00Z",
    TimeAnswered: "2024-01-15T10:15:02Z",
    TimeEnd: "2024-01-15T10:20:17Z",
    ReasonTerminated: "Normal",
    FromNo: "0923456789",
    ToNo: "0987654321",
    FromDN: "ext104",
    ToDN: "ext102",
    DialNo: "0987654321",
    ReasonChanged: "",
    FinalNumber: "0987654321",
    FinalDN: "ext102",
    BillCode: "LOCAL",
    BillRate: 100.00,
    BillCost: 2000.00,
    BillName: "Local Rate",
    Chain: "ext104->ext102",
    FromType: "External",
    ToType: "Internal",
    FinalType: "Internal",
    FromDispName: "Phạm Thị D",
    ToDispName: "Trần Thị B",
    FinalDispName: "Trần Thị B",
    MissedQueueCalls: "",
    CallType: "Inbound",
    LeadStatus: 3,
    LeadStatusStr: "Thành công",
    StatusContent: "Khách hàng đã đồng ý mua hàng",
    CreatedTime: "2024-01-15T10:15:00Z",
    UpdatedTime: "2024-01-15T10:25:00Z",
    CreatedBy: 1,
    CreatedByUserName: "admin",
    UpdatedBy: 1,
    UpdatedByUserName: "admin"
  },
  {
    Id: 4,
    HistoryID: "CALL004",
    CallID: "3CX-12348",
    Duration: "00:01:20",
    TimeStart: "2024-01-15T11:30:00Z",
    TimeAnswered: "2024-01-15T11:30:08Z",
    TimeEnd: "2024-01-15T11:31:28Z",
    ReasonTerminated: "Normal",
    FromNo: "0934567890",
    ToNo: "0987654321",
    FromDN: "ext105",
    ToDN: "ext102",
    DialNo: "0987654321",
    ReasonChanged: "",
    FinalNumber: "0987654321",
    FinalDN: "ext102",
    BillCode: "LOCAL",
    BillRate: 100.00,
    BillCost: 500.00,
    BillName: "Local Rate",
    Chain: "ext105->ext102",
    FromType: "External",
    ToType: "Internal",
    FinalType: "Internal",
    FromDispName: "Hoàng Văn E",
    ToDispName: "Trần Thị B",
    FinalDispName: "Trần Thị B",
    MissedQueueCalls: "",
    CallType: "Inbound",
    LeadStatus: 4,
    LeadStatusStr: "Thất bại",
    StatusContent: "Khách hàng không quan tâm",
    CreatedTime: "2024-01-15T11:30:00Z",
    UpdatedTime: "2024-01-15T11:35:00Z",
    CreatedBy: 1,
    CreatedByUserName: "admin",
    UpdatedBy: 1,
    UpdatedByUserName: "admin"
  },
  {
    Id: 5,
    HistoryID: "CALL005",
    CallID: "3CX-12349",
    Duration: "00:04:30",
    TimeStart: "2024-01-15T14:00:00Z",
    TimeAnswered: "2024-01-15T14:00:05Z",
    TimeEnd: "2024-01-15T14:04:35Z",
    ReasonTerminated: "Normal",
    FromNo: "0987654321",
    ToNo: "0901234567",
    FromDN: "ext102",
    ToDN: "ext101",
    DialNo: "0901234567",
    ReasonChanged: "",
    FinalNumber: "0901234567",
    FinalDN: "ext101",
    BillCode: "LOCAL",
    BillRate: 100.00,
    BillCost: 1800.00,
    BillName: "Local Rate",
    Chain: "ext102->ext101",
    FromType: "Internal",
    ToType: "External",
    FinalType: "External",
    FromDispName: "Trần Thị B",
    ToDispName: "Nguyễn Văn A",
    FinalDispName: "Nguyễn Văn A",
    MissedQueueCalls: "",
    CallType: "Outbound",
    LeadStatus: 2,
    LeadStatusStr: "Đã tiếp nhận",
    StatusContent: "Gọi lại khách hàng để tư vấn thêm",
    CreatedTime: "2024-01-15T14:00:00Z",
    UpdatedTime: "2024-01-15T14:10:00Z",
    CreatedBy: 1,
    CreatedByUserName: "admin",
    UpdatedBy: 1,
    UpdatedByUserName: "admin"
  }
];

export const demoStatistics = {
  totalCalls: 1250,
  totalDuration: 18750.5,
  totalCost: 125000.00,
  callsByStatus: [
    {
      status: "New",
      count: 500
    },
    {
      status: "Assigned", 
      count: 300
    },
    {
      status: "Success",
      count: 350
    },
    {
      status: "Failed",
      count: 100
    }
  ],
  callsByType: [
    {
      type: "Inbound",
      count: 800
    },
    {
      type: "Outbound",
      count: 450
    }
  ]
};

export const demoSearchResult = {
  Items: demoCallLogs,
  TotalRecord: 5,
  NumberOfPages: 1,
  From: 1,
  To: 5,
  LastPage: 1
};

// Helper functions for demo
export const createDemoCallLog = () => {
  const now = new Date();
  const id = Math.floor(Math.random() * 10000);
  
  return {
    Id: 0, // 0 for new record
    HistoryID: `CALL${String(id).padStart(6, '0')}`,
    CallID: `3CX-${id}`,
    Duration: "00:00:00",
    TimeStart: now.toISOString(),
    TimeAnswered: null,
    TimeEnd: null,
    ReasonTerminated: "",
    FromNo: "",
    ToNo: "",
    FromDN: "",
    ToDN: "",
    DialNo: "",
    ReasonChanged: "",
    FinalNumber: "",
    FinalDN: "",
    BillCode: "LOCAL",
    BillRate: 100.00,
    BillCost: 0.00,
    BillName: "Local Rate",
    Chain: "",
    FromType: "External",
    ToType: "Internal",
    FinalType: "Internal",
    FromDispName: "",
    ToDispName: "",
    FinalDispName: "",
    MissedQueueCalls: "",
    CallType: "Inbound",
    LeadStatus: 1,
    StatusContent: ""
  };
};

export const getRandomPhoneNumber = () => {
  const prefixes = ['090', '091', '092', '093', '094', '095', '096', '097', '098', '099'];
  const prefix = prefixes[Math.floor(Math.random() * prefixes.length)];
  const suffix = Math.floor(Math.random() * 10000000).toString().padStart(7, '0');
  return prefix + suffix;
};

export const getRandomDuration = () => {
  const minutes = Math.floor(Math.random() * 10);
  const seconds = Math.floor(Math.random() * 60);
  return `00:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
};

export const getRandomLeadStatus = () => {
  return Math.floor(Math.random() * 4) + 1; // 1-4
};

export const getRandomCallType = () => {
  return Math.random() > 0.5 ? 'Inbound' : 'Outbound';
};
