import { Subscription, SubscriptionStatus, SubscriptionPlan, SubscriptionTier } from '@prisma/client'
import { customerUser, customerUser2 } from './users'

// Active subscription
export const activeSubscription: Subscription = {
  id: 'sub-001',
  userId: customerUser.id,
  status: SubscriptionStatus.ACTIVE,
  plan: SubscriptionPlan.PRO,
  tier: SubscriptionTier.ADVANCED,
  tokenLimit: 50000,
  tokensUsed: 12500,
  trialEndsAt: null,
  stripeCustomerId: 'cus_test123',
  stripeSubscriptionId: 'sub_test123',
  createdAt: new Date('2024-01-01T00:00:00Z'),
  updatedAt: new Date('2024-01-01T00:00:00Z'),
}

// Trial subscription
export const trialSubscription: Subscription = {
  id: 'sub-002',
  userId: customerUser2.id,
  status: SubscriptionStatus.TRIAL,
  plan: SubscriptionPlan.TRIAL,
  tier: SubscriptionTier.HUB_DASHBOARD,
  tokenLimit: 10000,
  tokensUsed: 500,
  trialEndsAt: new Date('2024-01-29T00:00:00Z'), // 14-day trial
  stripeCustomerId: null,
  stripeSubscriptionId: null,
  createdAt: new Date('2024-01-15T00:00:00Z'),
  updatedAt: new Date('2024-01-15T00:00:00Z'),
}

// Cancelled subscription
export const cancelledSubscription: Subscription = {
  id: 'sub-003',
  userId: customerUser.id,
  status: SubscriptionStatus.CANCELED,
  plan: SubscriptionPlan.PRO,
  tier: SubscriptionTier.ADVANCED,
  tokenLimit: 50000,
  tokensUsed: 45000,
  trialEndsAt: null,
  stripeCustomerId: 'cus_test789',
  stripeSubscriptionId: 'sub_test789',
  createdAt: new Date('2023-12-01T00:00:00Z'),
  updatedAt: new Date('2024-01-20T00:00:00Z'),
}

// Past due subscription
export const pastDueSubscription: Subscription = {
  id: 'sub-004',
  userId: customerUser.id,
  status: SubscriptionStatus.PAST_DUE,
  plan: SubscriptionPlan.ENTERPRISE,
  tier: SubscriptionTier.ADVANCED,
  tokenLimit: 100000,
  tokensUsed: 78000,
  trialEndsAt: null,
  stripeCustomerId: 'cus_testABC',
  stripeSubscriptionId: 'sub_testABC',
  createdAt: new Date('2023-06-01T00:00:00Z'),
  updatedAt: new Date('2024-01-20T00:00:00Z'),
}

// All subscriptions
export const allSubscriptions: Subscription[] = [
  activeSubscription,
  trialSubscription,
  cancelledSubscription,
  pastDueSubscription,
]

// Factory function for creating custom subscriptions
export function createSubscription(overrides: Partial<Subscription> = {}): Subscription {
  const now = new Date()

  return {
    id: `sub-${Date.now()}`,
    userId: customerUser.id,
    status: SubscriptionStatus.ACTIVE,
    plan: SubscriptionPlan.STARTER,
    tier: SubscriptionTier.HUB_DASHBOARD,
    tokenLimit: 25000,
    tokensUsed: 0,
    trialEndsAt: null,
    stripeCustomerId: `cus_${Date.now()}`,
    stripeSubscriptionId: `sub_${Date.now()}`,
    createdAt: now,
    updatedAt: now,
    ...overrides,
  }
}
