/**
 * Subscription Type Definitions
 *
 * Core interfaces for subscription management, checkout flows, and payment status.
 */

/**
 * Subscription status returned from /api/subscription/status
 */
export interface SubscriptionStatusResponse {
  hasActiveSubscription: boolean;
  needsPayment: boolean;
  subscription: {
    id: string;
    tierId: string;
    status: string;
    billingPeriod: string;
    currentPeriodEnd: Date | null;
    trialEndsAt: Date | null;
    cancelAtPeriodEnd: boolean;
    setupFeePaid: boolean;
  } | null;
  user: {
    id: string;
    email: string;
    name: string | null;
    stripeCustomerId: string | null;
  };
  /**
   * Organization information when user has access via org membership
   * Only populated when subscription is inherited from organization owner
   */
  organization?: {
    id: string;
    name: string;
    role: string;
  };
}

/**
 * Request body for existing user checkout session creation
 */
export interface ExistingUserCheckoutRequest {
  tierId: string;
  billingPeriod: 'monthly' | 'yearly';
  currency: string;
}

/**
 * Response from checkout session creation
 */
export interface CheckoutResponse {
  url: string;
  sessionId: string;
}

/**
 * Subscription details for PaymentRequiredOverlay
 */
export interface SubscriptionDetails {
  tier?: string;
  status?: string;
  needsPayment?: boolean;
  currentPeriodEnd?: string;
  cancelAtPeriodEnd?: boolean;
}
