/**
 * @ai-summary User profile domain types
 * @ai-context Type definitions for user profile data models
 */

// Subscription tier enum
export type SubscriptionTier = 'free' | 'pro' | 'enterprise';

export interface UserProfile {
  id: string;
  auth0Sub: string;
  email: string;
  displayName?: string;
  notificationEmail?: string;
  subscriptionTier: SubscriptionTier;
  emailVerified: boolean;
  onboardingCompletedAt: Date | null;
  deactivatedAt: Date | null;
  deactivatedBy: string | null;
  deletionRequestedAt: Date | null;
  deletionScheduledFor: Date | null;
  createdAt: Date;
  updatedAt: Date;
}

// User with admin status for admin views (joined from admin_users table)
export interface UserWithAdminStatus extends UserProfile {
  isAdmin: boolean;
  adminRole: 'admin' | 'super_admin' | null;
  vehicleCount: number;
}

// Pagination and filter query params for listing users
export interface ListUsersQuery {
  page?: number;
  pageSize?: number;
  search?: string;
  tier?: SubscriptionTier;
  status?: 'active' | 'deactivated' | 'all';
  sortBy?: 'email' | 'createdAt' | 'displayName' | 'subscriptionTier' | 'vehicleCount';
  sortOrder?: 'asc' | 'desc';
}

// Paginated response for user listing
export interface ListUsersResponse {
  users: UserWithAdminStatus[];
  total: number;
  page: number;
  pageSize: number;
}

// Request to update subscription tier
export interface UpdateTierRequest {
  subscriptionTier: SubscriptionTier;
}

// Request to deactivate a user
export interface DeactivateUserRequest {
  reason?: string;
}

export interface UpdateProfileRequest {
  displayName?: string;
  notificationEmail?: string;
}

export interface Auth0UserData {
  sub: string;
  email: string;
  name?: string;
}

// Request to delete user account
export interface RequestDeletionRequest {
  password: string;
  confirmationText: string;
}

// Deletion status for user account
export interface DeletionStatus {
  isPendingDeletion: boolean;
  deletionRequestedAt: Date | null;
  deletionScheduledFor: Date | null;
  daysRemaining: number | null;
}
