import type {
  AvailableBatch,
  DistributionRecord,
  QuotaStatus,
} from "@/types/api"

// Generate dates spread across last 30 days
function daysAgo(days: number, hours: number, minutes: number): string {
  const d = new Date()
  d.setDate(d.getDate() - days)
  d.setHours(hours, minutes, 0, 0)
  return d.toISOString()
}

export const mockDistributions: DistributionRecord[] = [
  // Today (8 records)
  {
    id: "dist-001",
    memberId: "m-001",
    memberName: "Thomas Müller",
    batchId: "b-001",
    strainName: "Amnesia Haze",
    amountGrams: 5,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(0, 16, 10),
    status: "COMPLETED",
  },
  {
    id: "dist-002",
    memberId: "m-002",
    memberName: "Anna Schmidt",
    batchId: "b-003",
    strainName: "Northern Lights",
    amountGrams: 3,
    recordedBy: "Thomas Klein",
    recordedAt: daysAgo(0, 15, 30),
    status: "COMPLETED",
  },
  {
    id: "dist-003",
    memberId: "m-003",
    memberName: "Markus Weber",
    batchId: "b-002",
    strainName: "White Widow",
    amountGrams: 7,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(0, 14, 45),
    status: "COMPLETED",
  },
  {
    id: "dist-004",
    memberId: "m-006",
    memberName: "Lisa Hoffmann",
    batchId: "b-004",
    strainName: "Jack Herer",
    amountGrams: 10,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(0, 13, 20),
    status: "COMPLETED",
  },
  {
    id: "dist-005",
    memberId: "m-008",
    memberName: "Sabine Koch",
    batchId: "b-005",
    strainName: "Blue Dream",
    amountGrams: 4,
    recordedBy: "Thomas Klein",
    recordedAt: daysAgo(0, 12, 0),
    status: "COMPLETED",
  },
  {
    id: "dist-006",
    memberId: "m-009",
    memberName: "Christian Braun",
    batchId: "b-001",
    strainName: "Amnesia Haze",
    amountGrams: 8,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(0, 11, 15),
    status: "COMPLETED",
  },
  {
    id: "dist-007",
    memberId: "m-010",
    memberName: "Petra Richter",
    batchId: "b-006",
    strainName: "Girl Scout Cookies",
    amountGrams: 6,
    recordedBy: "Thomas Klein",
    recordedAt: daysAgo(0, 10, 30),
    status: "COMPLETED",
  },
  {
    id: "dist-008",
    memberId: "m-004",
    memberName: "Julia Fischer",
    batchId: "b-002",
    strainName: "White Widow",
    amountGrams: 2.5,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(0, 9, 45),
    status: "COMPLETED",
  },
  // Yesterday (6 records)
  {
    id: "dist-009",
    memberId: "m-011",
    memberName: "Michael Wagner",
    batchId: "b-003",
    strainName: "Northern Lights",
    amountGrams: 12,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(1, 16, 0),
    status: "COMPLETED",
  },
  {
    id: "dist-010",
    memberId: "m-012",
    memberName: "Sandra Klein",
    batchId: "b-001",
    strainName: "Amnesia Haze",
    amountGrams: 5,
    recordedBy: "Thomas Klein",
    recordedAt: daysAgo(1, 14, 30),
    status: "COMPLETED",
  },
  {
    id: "dist-011",
    memberId: "m-001",
    memberName: "Thomas Müller",
    batchId: "b-004",
    strainName: "Jack Herer",
    amountGrams: 8,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(1, 13, 0),
    status: "COMPLETED",
  },
  {
    id: "dist-012",
    memberId: "m-003",
    memberName: "Markus Weber",
    batchId: "b-005",
    strainName: "Blue Dream",
    amountGrams: 3.5,
    recordedBy: "Thomas Klein",
    recordedAt: daysAgo(1, 11, 45),
    status: "COMPLETED",
  },
  {
    id: "dist-013",
    memberId: "m-006",
    memberName: "Lisa Hoffmann",
    batchId: "b-002",
    strainName: "White Widow",
    amountGrams: 6,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(1, 10, 20),
    status: "COMPLETED",
  },
  {
    id: "dist-014",
    memberId: "m-007",
    memberName: "Daniel Schäfer",
    batchId: "b-006",
    strainName: "Girl Scout Cookies",
    amountGrams: 4,
    recordedBy: "Thomas Klein",
    recordedAt: daysAgo(1, 9, 15),
    status: "COMPLETED",
  },
  // 2 days ago (5 records)
  {
    id: "dist-015",
    memberId: "m-002",
    memberName: "Anna Schmidt",
    batchId: "b-001",
    strainName: "Amnesia Haze",
    amountGrams: 10,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(2, 15, 30),
    status: "COMPLETED",
  },
  {
    id: "dist-016",
    memberId: "m-008",
    memberName: "Sabine Koch",
    batchId: "b-003",
    strainName: "Northern Lights",
    amountGrams: 7,
    recordedBy: "Thomas Klein",
    recordedAt: daysAgo(2, 14, 0),
    status: "COMPLETED",
  },
  {
    id: "dist-017",
    memberId: "m-009",
    memberName: "Christian Braun",
    batchId: "b-004",
    strainName: "Jack Herer",
    amountGrams: 15,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(2, 12, 30),
    status: "COMPLETED",
  },
  {
    id: "dist-018",
    memberId: "m-010",
    memberName: "Petra Richter",
    batchId: "b-005",
    strainName: "Blue Dream",
    amountGrams: 5,
    recordedBy: "Thomas Klein",
    recordedAt: daysAgo(2, 11, 0),
    status: "COMPLETED",
  },
  {
    id: "dist-019",
    memberId: "m-004",
    memberName: "Julia Fischer",
    batchId: "b-002",
    strainName: "White Widow",
    amountGrams: 3,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(2, 9, 30),
    status: "COMPLETED",
  },
  // 3-5 days ago
  {
    id: "dist-020",
    memberId: "m-011",
    memberName: "Michael Wagner",
    batchId: "b-001",
    strainName: "Amnesia Haze",
    amountGrams: 8,
    recordedBy: "Thomas Klein",
    recordedAt: daysAgo(3, 15, 0),
    status: "COMPLETED",
  },
  {
    id: "dist-021",
    memberId: "m-012",
    memberName: "Sandra Klein",
    batchId: "b-006",
    strainName: "Girl Scout Cookies",
    amountGrams: 6,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(3, 13, 30),
    status: "COMPLETED",
  },
  {
    id: "dist-022",
    memberId: "m-001",
    memberName: "Thomas Müller",
    batchId: "b-003",
    strainName: "Northern Lights",
    amountGrams: 10,
    recordedBy: "Thomas Klein",
    recordedAt: daysAgo(4, 16, 0),
    status: "COMPLETED",
  },
  {
    id: "dist-023",
    memberId: "m-002",
    memberName: "Anna Schmidt",
    batchId: "b-004",
    strainName: "Jack Herer",
    amountGrams: 4,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(4, 14, 15),
    status: "COMPLETED",
  },
  {
    id: "dist-024",
    memberId: "m-006",
    memberName: "Lisa Hoffmann",
    batchId: "b-001",
    strainName: "Amnesia Haze",
    amountGrams: 9,
    recordedBy: "Thomas Klein",
    recordedAt: daysAgo(5, 15, 30),
    status: "COMPLETED",
  },
  {
    id: "dist-025",
    memberId: "m-008",
    memberName: "Sabine Koch",
    batchId: "b-005",
    strainName: "Blue Dream",
    amountGrams: 11,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(5, 12, 0),
    status: "COMPLETED",
  },
  // 6-14 days ago
  {
    id: "dist-026",
    memberId: "m-009",
    memberName: "Christian Braun",
    batchId: "b-002",
    strainName: "White Widow",
    amountGrams: 7,
    recordedBy: "Thomas Klein",
    recordedAt: daysAgo(7, 14, 0),
    status: "COMPLETED",
  },
  {
    id: "dist-027",
    memberId: "m-003",
    memberName: "Markus Weber",
    batchId: "b-006",
    strainName: "Girl Scout Cookies",
    amountGrams: 5,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(8, 11, 30),
    status: "COMPLETED",
  },
  {
    id: "dist-028",
    memberId: "m-010",
    memberName: "Petra Richter",
    batchId: "b-003",
    strainName: "Northern Lights",
    amountGrams: 13,
    recordedBy: "Thomas Klein",
    recordedAt: daysAgo(10, 15, 45),
    status: "COMPLETED",
  },
  {
    id: "dist-029",
    memberId: "m-004",
    memberName: "Julia Fischer",
    batchId: "b-001",
    strainName: "Amnesia Haze",
    amountGrams: 6,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(12, 13, 20),
    status: "COMPLETED",
  },
  {
    id: "dist-030",
    memberId: "m-007",
    memberName: "Daniel Schäfer",
    batchId: "b-004",
    strainName: "Jack Herer",
    amountGrams: 3,
    recordedBy: "Thomas Klein",
    recordedAt: daysAgo(14, 10, 0),
    status: "COMPLETED",
  },
  // 15-30 days ago
  {
    id: "dist-031",
    memberId: "m-011",
    memberName: "Michael Wagner",
    batchId: "b-005",
    strainName: "Blue Dream",
    amountGrams: 8,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(16, 14, 30),
    status: "COMPLETED",
  },
  {
    id: "dist-032",
    memberId: "m-012",
    memberName: "Sandra Klein",
    batchId: "b-002",
    strainName: "White Widow",
    amountGrams: 10,
    recordedBy: "Thomas Klein",
    recordedAt: daysAgo(20, 11, 0),
    status: "COMPLETED",
  },
  {
    id: "dist-033",
    memberId: "m-001",
    memberName: "Thomas Müller",
    batchId: "b-006",
    strainName: "Girl Scout Cookies",
    amountGrams: 4,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(22, 16, 0),
    status: "COMPLETED",
  },
  {
    id: "dist-034",
    memberId: "m-006",
    memberName: "Lisa Hoffmann",
    batchId: "b-003",
    strainName: "Northern Lights",
    amountGrams: 12,
    recordedBy: "Thomas Klein",
    recordedAt: daysAgo(25, 13, 0),
    status: "COMPLETED",
  },
  {
    id: "dist-035",
    memberId: "m-009",
    memberName: "Christian Braun",
    batchId: "b-001",
    strainName: "Amnesia Haze",
    amountGrams: 7,
    recordedBy: "Maria Schulz",
    recordedAt: daysAgo(28, 15, 0),
    status: "COMPLETED",
  },
]

// Quota mock for different members
export function getMockQuota(memberId: string): QuotaStatus {
  const quotas: Record<string, QuotaStatus> = {
    "m-001": {
      dailyUsedGrams: 5,
      dailyLimitGrams: 25,
      monthlyUsedGrams: 23,
      monthlyLimitGrams: 50,
      isUnder21: false,
    },
    "m-002": {
      dailyUsedGrams: 3,
      dailyLimitGrams: 25,
      monthlyUsedGrams: 36,
      monthlyLimitGrams: 50,
      isUnder21: false,
    },
    "m-003": {
      dailyUsedGrams: 7,
      dailyLimitGrams: 25,
      monthlyUsedGrams: 15,
      monthlyLimitGrams: 50,
      isUnder21: false,
    },
    "m-004": {
      dailyUsedGrams: 2.5,
      dailyLimitGrams: 25,
      monthlyUsedGrams: 44,
      monthlyLimitGrams: 50,
      isUnder21: false,
    },
    "m-006": {
      dailyUsedGrams: 10,
      dailyLimitGrams: 25,
      monthlyUsedGrams: 27.5,
      monthlyLimitGrams: 50,
      isUnder21: false,
    },
    "m-007": {
      dailyUsedGrams: 4,
      dailyLimitGrams: 25,
      monthlyUsedGrams: 7,
      monthlyLimitGrams: 30,
      isUnder21: true,
    },
    "m-008": {
      dailyUsedGrams: 4,
      dailyLimitGrams: 25,
      monthlyUsedGrams: 20,
      monthlyLimitGrams: 50,
      isUnder21: false,
    },
    "m-009": {
      dailyUsedGrams: 8,
      dailyLimitGrams: 25,
      monthlyUsedGrams: 30,
      monthlyLimitGrams: 50,
      isUnder21: false,
    },
    "m-010": {
      dailyUsedGrams: 6,
      dailyLimitGrams: 25,
      monthlyUsedGrams: 18,
      monthlyLimitGrams: 50,
      isUnder21: false,
    },
  }
  return (
    quotas[memberId] ?? {
      dailyUsedGrams: 0,
      dailyLimitGrams: 25,
      monthlyUsedGrams: 0,
      monthlyLimitGrams: 50,
      isUnder21: false,
    }
  )
}

export const mockAvailableBatches: AvailableBatch[] = [
  {
    id: "b-001",
    strainName: "Amnesia Haze",
    availableGrams: 520,
    thcPercent: 22.5,
    status: "AVAILABLE",
  },
  {
    id: "b-002",
    strainName: "White Widow",
    availableGrams: 430,
    thcPercent: 18.0,
    status: "AVAILABLE",
  },
  {
    id: "b-003",
    strainName: "Northern Lights",
    availableGrams: 380,
    thcPercent: 16.5,
    status: "AVAILABLE",
  },
  {
    id: "b-004",
    strainName: "Jack Herer",
    availableGrams: 450,
    thcPercent: 20.0,
    status: "AVAILABLE",
  },
  {
    id: "b-005",
    strainName: "Blue Dream",
    availableGrams: 340,
    thcPercent: 21.0,
    status: "AVAILABLE",
  },
  {
    id: "b-006",
    strainName: "Girl Scout Cookies",
    availableGrams: 230,
    thcPercent: 24.0,
    status: "AVAILABLE",
  },
]
