export type UserRole = "super_admin" | "tenant_admin" | "manager" | "employee";
export type UserStatus = "active" | "suspended";
export type TaskStatus = "pending" | "in_progress" | "completed";
export type TaskPriority = "high" | "medium" | "low";

export interface MockUser {
  id: number;
  tenantId: number;
  tenantName: string;
  name: string;
  email: string;
  role: UserRole;
  status: UserStatus;
  tasksAssigned: number;
  tasksCompleted: number;
  avatar: string;
  createdAt: string;
}

export interface MockTenant {
  id: number;
  name: string;
  domain: string;
  industry: string;
  status: string;
  userCount: number;
  createdAt: string;
}

export interface MockSubtask {
  id: number;
  taskId: number;
  title: string;
  status: TaskStatus;
  priority: TaskPriority;
  assignedUserId: number | null;
  assignedUserName: string | null;
  dueDate: string | null;
}

export interface MockTask {
  id: number;
  tenantId: number;
  title: string;
  description: string;
  status: TaskStatus;
  priority: TaskPriority;
  assignedUserId: number | null;
  assignedUserName: string | null;
  dueDate: string | null;
  completionPercent: number;
  subtaskCount: number;
  completedSubtaskCount: number;
  createdAt: string;
  updatedAt: string;
}

export interface MockDocument {
  id: number;
  tenantId: number;
  name: string;
  mimeType: string;
  sizeBytes: number;
  taskId: number | null;
  taskTitle: string | null;
  uploadedByUserId: number;
  uploadedByName: string;
  url: string;
  createdAt: string;
}

export interface MockSubscriptionPlan {
  id: number;
  name: string;
  description: string;
  maxUsers: number;
  pricePerMonth: number;
  features: string[];
  popular?: boolean;
}

export interface MockBillingRecord {
  id: number;
  planName: string;
  amount: number;
  status: string;
  billingDate: string;
  description: string;
}

export interface MockRole {
  id: number;
  tenantId: number;
  name: string;
  description: string;
  permissions: string[];
  userCount: number;
  createdAt: string;
}

export interface MockActivityLog {
  id: number;
  userId: number | null;
  userName: string | null;
  action: string;
  entityType: string;
  entityTitle: string | null;
  createdAt: string;
}

export const CURRENT_USER: MockUser = {
  id: 1,
  tenantId: 1,
  tenantName: "Acme Corporation",
  name: "Alex Johnson",
  email: "admin@acme.corp",
  role: "tenant_admin",
  status: "active",
  tasksAssigned: 3,
  tasksCompleted: 1,
  avatar: "AJ",
  createdAt: "2025-01-15T09:00:00Z",
};

export const CURRENT_TENANT: MockTenant = {
  id: 1,
  name: "Acme Corporation",
  domain: "acme.corp",
  industry: "Technology",
  status: "active",
  userCount: 5,
  createdAt: "2025-01-01T00:00:00Z",
};

export const MOCK_USERS: MockUser[] = [
  {
    id: 1,
    tenantId: 1,
    tenantName: "Acme Corporation",
    name: "Alex Johnson",
    email: "admin@acme.corp",
    role: "tenant_admin",
    status: "active",
    tasksAssigned: 3,
    tasksCompleted: 1,
    avatar: "AJ",
    createdAt: "2025-01-15T09:00:00Z",
  },
  {
    id: 2,
    tenantId: 1,
    tenantName: "Acme Corporation",
    name: "Sarah Chen",
    email: "sarah@acme.corp",
    role: "manager",
    status: "active",
    tasksAssigned: 5,
    tasksCompleted: 3,
    avatar: "SC",
    createdAt: "2025-01-20T10:00:00Z",
  },
  {
    id: 3,
    tenantId: 1,
    tenantName: "Acme Corporation",
    name: "Marcus Williams",
    email: "marcus@acme.corp",
    role: "employee",
    status: "active",
    tasksAssigned: 4,
    tasksCompleted: 2,
    avatar: "MW",
    createdAt: "2025-02-01T11:00:00Z",
  },
  {
    id: 4,
    tenantId: 1,
    tenantName: "Acme Corporation",
    name: "Priya Patel",
    email: "priya@acme.corp",
    role: "employee",
    status: "active",
    tasksAssigned: 3,
    tasksCompleted: 3,
    avatar: "PP",
    createdAt: "2025-02-10T09:30:00Z",
  },
  {
    id: 5,
    tenantId: 1,
    tenantName: "Acme Corporation",
    name: "David Kim",
    email: "david@acme.corp",
    role: "employee",
    status: "suspended",
    tasksAssigned: 1,
    tasksCompleted: 0,
    avatar: "DK",
    createdAt: "2025-02-15T14:00:00Z",
  },
];

export const MOCK_SUBTASKS: MockSubtask[] = [
  { id: 1, taskId: 1, title: "User research and interviews", status: "completed", priority: "high", assignedUserId: 2, assignedUserName: "Sarah Chen", dueDate: "2025-04-10" },
  { id: 2, taskId: 1, title: "Wireframe design for new flow", status: "completed", priority: "high", assignedUserId: 4, assignedUserName: "Priya Patel", dueDate: "2025-04-15" },
  { id: 3, taskId: 1, title: "Prototype development", status: "in_progress", priority: "medium", assignedUserId: 3, assignedUserName: "Marcus Williams", dueDate: "2025-04-25" },
  { id: 4, taskId: 1, title: "A/B testing setup", status: "pending", priority: "medium", assignedUserId: 2, assignedUserName: "Sarah Chen", dueDate: "2025-04-30" },
  { id: 5, taskId: 2, title: "Research Stripe API documentation", status: "completed", priority: "high", assignedUserId: 3, assignedUserName: "Marcus Williams", dueDate: "2025-04-20" },
  { id: 6, taskId: 2, title: "Implement checkout flow", status: "in_progress", priority: "high", assignedUserId: 3, assignedUserName: "Marcus Williams", dueDate: "2025-05-05" },
  { id: 7, taskId: 2, title: "Webhook handling", status: "pending", priority: "high", assignedUserId: 3, assignedUserName: "Marcus Williams", dueDate: "2025-05-10" },
  { id: 8, taskId: 5, title: "Beta testing framework", status: "completed", priority: "medium", assignedUserId: 3, assignedUserName: "Marcus Williams", dueDate: "2025-04-20" },
  { id: 9, taskId: 5, title: "Feature flag implementation", status: "in_progress", priority: "medium", assignedUserId: 3, assignedUserName: "Marcus Williams", dueDate: "2025-04-28" },
];

export const MOCK_TASKS: MockTask[] = [
  {
    id: 1,
    tenantId: 1,
    title: "Redesign customer onboarding flow",
    description: "Improve the sign-up and onboarding experience for new customers to reduce drop-off rates.",
    status: "in_progress",
    priority: "high",
    assignedUserId: 2,
    assignedUserName: "Sarah Chen",
    dueDate: "2025-04-30",
    completionPercent: 50,
    subtaskCount: 4,
    completedSubtaskCount: 2,
    createdAt: "2025-03-01T09:00:00Z",
    updatedAt: "2025-04-09T14:00:00Z",
  },
  {
    id: 2,
    tenantId: 1,
    title: "Implement payment gateway integration",
    description: "Integrate Stripe for subscription billing and one-time payments.",
    status: "in_progress",
    priority: "high",
    assignedUserId: 3,
    assignedUserName: "Marcus Williams",
    dueDate: "2025-05-15",
    completionPercent: 33,
    subtaskCount: 3,
    completedSubtaskCount: 1,
    createdAt: "2025-03-05T10:00:00Z",
    updatedAt: "2025-04-08T11:00:00Z",
  },
  {
    id: 3,
    tenantId: 1,
    title: "Q2 performance review documentation",
    description: "Prepare all documentation and materials for the Q2 performance reviews.",
    status: "completed",
    priority: "medium",
    assignedUserId: 4,
    assignedUserName: "Priya Patel",
    dueDate: "2025-04-10",
    completionPercent: 100,
    subtaskCount: 0,
    completedSubtaskCount: 0,
    createdAt: "2025-03-10T09:00:00Z",
    updatedAt: "2025-04-08T16:00:00Z",
  },
  {
    id: 4,
    tenantId: 1,
    title: "Security audit and penetration testing",
    description: "Conduct full security audit with external security team. Critical for compliance.",
    status: "pending",
    priority: "high",
    assignedUserId: 2,
    assignedUserName: "Sarah Chen",
    dueDate: "2025-05-20",
    completionPercent: 0,
    subtaskCount: 0,
    completedSubtaskCount: 0,
    createdAt: "2025-03-15T10:00:00Z",
    updatedAt: "2025-03-15T10:00:00Z",
  },
  {
    id: 5,
    tenantId: 1,
    title: "Mobile app beta release",
    description: "Launch beta version of the mobile app to a select group of test users.",
    status: "in_progress",
    priority: "medium",
    assignedUserId: 3,
    assignedUserName: "Marcus Williams",
    dueDate: "2025-05-01",
    completionPercent: 50,
    subtaskCount: 2,
    completedSubtaskCount: 1,
    createdAt: "2025-03-20T11:00:00Z",
    updatedAt: "2025-04-07T09:00:00Z",
  },
  {
    id: 6,
    tenantId: 1,
    title: "Update API documentation",
    description: "Rewrite and update all API documentation to reflect v2 changes.",
    status: "completed",
    priority: "low",
    assignedUserId: 4,
    assignedUserName: "Priya Patel",
    dueDate: "2025-04-05",
    completionPercent: 100,
    subtaskCount: 0,
    completedSubtaskCount: 0,
    createdAt: "2025-03-25T09:00:00Z",
    updatedAt: "2025-04-05T17:00:00Z",
  },
  {
    id: 7,
    tenantId: 1,
    title: "Data migration to new infrastructure",
    description: "Migrate production database to new cloud infrastructure with zero downtime.",
    status: "pending",
    priority: "high",
    assignedUserId: 1,
    assignedUserName: "Alex Johnson",
    dueDate: "2025-06-01",
    completionPercent: 0,
    subtaskCount: 0,
    completedSubtaskCount: 0,
    createdAt: "2025-04-01T10:00:00Z",
    updatedAt: "2025-04-01T10:00:00Z",
  },
  {
    id: 8,
    tenantId: 1,
    title: "Customer satisfaction survey campaign",
    description: "Design and distribute Q2 customer satisfaction survey to all active customers.",
    status: "in_progress",
    priority: "low",
    assignedUserId: 3,
    assignedUserName: "Marcus Williams",
    dueDate: "2025-04-25",
    completionPercent: 20,
    subtaskCount: 0,
    completedSubtaskCount: 0,
    createdAt: "2025-04-02T09:00:00Z",
    updatedAt: "2025-04-07T11:00:00Z",
  },
];

export const MOCK_DOCUMENTS: MockDocument[] = [
  { id: 1, tenantId: 1, name: "Q2 Performance Review.pdf", mimeType: "application/pdf", sizeBytes: 2048576, taskId: 3, taskTitle: "Q2 performance review documentation", uploadedByUserId: 4, uploadedByName: "Priya Patel", url: "#", createdAt: "2025-04-08T16:00:00Z" },
  { id: 2, tenantId: 1, name: "Onboarding Flow Wireframes.fig", mimeType: "application/octet-stream", sizeBytes: 5120000, taskId: 1, taskTitle: "Redesign customer onboarding flow", uploadedByUserId: 4, uploadedByName: "Priya Patel", url: "#", createdAt: "2025-04-05T11:00:00Z" },
  { id: 3, tenantId: 1, name: "API Documentation v2.pdf", mimeType: "application/pdf", sizeBytes: 1048576, taskId: 6, taskTitle: "Update API documentation", uploadedByUserId: 4, uploadedByName: "Priya Patel", url: "#", createdAt: "2025-04-05T17:00:00Z" },
  { id: 4, tenantId: 1, name: "Security Audit Report.pdf", mimeType: "application/pdf", sizeBytes: 3145728, taskId: 4, taskTitle: "Security audit and penetration testing", uploadedByUserId: 2, uploadedByName: "Sarah Chen", url: "#", createdAt: "2025-04-06T09:00:00Z" },
  { id: 5, tenantId: 1, name: "Customer Survey Template.xlsx", mimeType: "application/vnd.ms-excel", sizeBytes: 524288, taskId: 8, taskTitle: "Customer satisfaction survey campaign", uploadedByUserId: 3, uploadedByName: "Marcus Williams", url: "#", createdAt: "2025-04-07T11:00:00Z" },
  { id: 6, tenantId: 1, name: "Mobile App Beta Notes.docx", mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", sizeBytes: 786432, taskId: 5, taskTitle: "Mobile app beta release", uploadedByUserId: 3, uploadedByName: "Marcus Williams", url: "#", createdAt: "2025-04-07T14:00:00Z" },
];

export const MOCK_SUBSCRIPTION_PLANS: MockSubscriptionPlan[] = [
  {
    id: 1,
    name: "Free",
    description: "Perfect for small teams getting started",
    maxUsers: 5,
    pricePerMonth: 0,
    features: ["Up to 5 users", "Task management", "Basic reporting", "5GB storage"],
  },
  {
    id: 2,
    name: "Pro",
    description: "For growing teams that need more power",
    maxUsers: 25,
    pricePerMonth: 49,
    features: ["Up to 25 users", "Advanced task management", "Analytics dashboard", "50GB storage", "Document management", "Role management", "Priority support"],
    popular: true,
  },
  {
    id: 3,
    name: "Enterprise",
    description: "Unlimited scale for large organizations",
    maxUsers: 999,
    pricePerMonth: 149,
    features: ["Unlimited users", "All Pro features", "Custom roles & permissions", "Unlimited storage", "Advanced analytics", "SSO integration", "Dedicated support", "SLA guarantee"],
  },
];

export const MOCK_BILLING_HISTORY: MockBillingRecord[] = [
  { id: 1, planName: "Pro", amount: 49, status: "paid", billingDate: "2025-04-01", description: "Monthly subscription - Pro plan - April 2025" },
  { id: 2, planName: "Pro", amount: 49, status: "paid", billingDate: "2025-03-01", description: "Monthly subscription - Pro plan - March 2025" },
  { id: 3, planName: "Pro", amount: 49, status: "paid", billingDate: "2025-02-01", description: "Monthly subscription - Pro plan - February 2025" },
  { id: 4, planName: "Free", amount: 0, status: "paid", billingDate: "2025-01-01", description: "Monthly subscription - Free plan - January 2025" },
];

export const MOCK_ROLES: MockRole[] = [
  { id: 1, tenantId: 1, name: "Company Admin", description: "Full access to all resources and settings", permissions: ["tasks:manage", "users:manage", "documents:manage", "billing:manage", "roles:manage"], userCount: 1, createdAt: "2025-01-01T00:00:00Z" },
  { id: 2, tenantId: 1, name: "Manager", description: "Manage tasks and team members within the company", permissions: ["tasks:manage", "users:read", "documents:manage"], userCount: 1, createdAt: "2025-01-01T00:00:00Z" },
  { id: 3, tenantId: 1, name: "Employee", description: "View and update tasks assigned to them", permissions: ["tasks:read", "tasks:update", "documents:read"], userCount: 3, createdAt: "2025-01-01T00:00:00Z" },
];

export const MOCK_TENANTS: MockTenant[] = [
  { id: 1, name: "Acme Corporation", domain: "acme.corp", industry: "Technology", status: "active", userCount: 5, createdAt: "2025-01-01T00:00:00Z" },
  { id: 2, name: "Globex Industries", domain: "globex.com", industry: "Manufacturing", status: "active", userCount: 12, createdAt: "2025-01-15T00:00:00Z" },
  { id: 3, name: "Initech Software", domain: "initech.io", industry: "Software", status: "active", userCount: 8, createdAt: "2025-02-01T00:00:00Z" },
  { id: 4, name: "Umbrella Corp", domain: "umbrella.corp", industry: "Healthcare", status: "suspended", userCount: 3, createdAt: "2025-02-20T00:00:00Z" },
];

export const MOCK_ACTIVITY: MockActivityLog[] = [
  { id: 1, userId: 2, userName: "Sarah Chen", action: "created", entityType: "task", entityTitle: "Redesign customer onboarding flow", createdAt: "2025-04-09T09:00:00Z" },
  { id: 2, userId: 3, userName: "Marcus Williams", action: "updated", entityType: "task", entityTitle: "Implement payment gateway integration", createdAt: "2025-04-08T15:30:00Z" },
  { id: 3, userId: 4, userName: "Priya Patel", action: "completed", entityType: "task", entityTitle: "Q2 performance review documentation", createdAt: "2025-04-08T14:00:00Z" },
  { id: 4, userId: 1, userName: "Alex Johnson", action: "created", entityType: "user", entityTitle: "Marcus Williams", createdAt: "2025-04-07T10:00:00Z" },
  { id: 5, userId: 3, userName: "Marcus Williams", action: "uploaded", entityType: "document", entityTitle: "Mobile App Beta Notes.docx", createdAt: "2025-04-07T09:00:00Z" },
  { id: 6, userId: 4, userName: "Priya Patel", action: "completed", entityType: "subtask", entityTitle: "Wireframe design for new flow", createdAt: "2025-04-06T16:00:00Z" },
  { id: 7, userId: 2, userName: "Sarah Chen", action: "updated", entityType: "task", entityTitle: "Mobile app beta release", createdAt: "2025-04-06T11:00:00Z" },
  { id: 8, userId: 1, userName: "Alex Johnson", action: "upgraded", entityType: "subscription", entityTitle: "Pro plan", createdAt: "2025-04-05T09:00:00Z" },
  { id: 9, userId: 2, userName: "Sarah Chen", action: "created", entityType: "task", entityTitle: "Data migration to new infrastructure", createdAt: "2025-04-04T14:00:00Z" },
  { id: 10, userId: 3, userName: "Marcus Williams", action: "completed", entityType: "subtask", entityTitle: "Research Stripe API documentation", createdAt: "2025-04-03T17:00:00Z" },
];

export const DASHBOARD_STATS = {
  totalUsers: 5,
  activeUsers: 4,
  totalTasks: 8,
  completedTasks: 2,
  inProgressTasks: 4,
  pendingTasks: 2,
  totalDocuments: 6,
  overallCompletionPercent: 44,
  tasksByPriority: { high: 4, medium: 2, low: 2 },
};

export const USER_PERFORMANCE = MOCK_USERS.map(u => ({
  userId: u.id,
  name: u.name,
  role: u.role,
  tasksAssigned: u.tasksAssigned,
  tasksCompleted: u.tasksCompleted,
  performancePercent: u.tasksAssigned === 0 ? 0 : Math.round((u.tasksCompleted / u.tasksAssigned) * 100),
}));

export const CURRENT_SUBSCRIPTION = {
  planId: 2,
  planName: "Pro",
  status: "active",
  currentPeriodStart: "2025-04-01",
  currentPeriodEnd: "2025-05-01",
  activeUsers: 4,
  maxUsers: 25,
  pricePerMonth: 49,
};
