import type {
  UserRole,
  MembershipType,
  MembershipStatus,
  Gender,
  ActivityLevel,
  GoalType,
  GoalStatus,
  PriorityLevel,
  AttendanceType,
  PaymentStatus,
  PaymentMethod,
  NotificationType,
  GymStatus,
  RecommendationStatus,
} from "../constants";

export interface User {
  id: string;
  email: string;
  firstName: string;
  lastName: string;
  password?: string;
  phone?: string;
  role: UserRole;
  gymId?: string;
  imageUrl?: string;
  expoPushToken?: string;
  deviceType?: "ios" | "android";
  createdAt: Date;
  updatedAt: Date;
}

export interface Client {
  id: string;
  userId: string;
  user?: User;
  membershipType: MembershipType;
  membershipStatus: MembershipStatus;
  joinDate: Date;
  lastVisit?: Date;
  emergencyContact?: {
    name: string;
    phone: string;
    relationship: string;
  };
}

export interface FitnessProfile {
  id: string;
  userId: string;
  height?: number; // in cm (fixed from string to number)
  weight?: number; // in kg (fixed from string to number)
  age?: number; // (fixed from string to number)
  gender?: Gender;
  activityLevel?: ActivityLevel;
  fitnessGoals?: string[];
  medicalConditions?: string;
  allergies?: string;
  injuries?: string;
  createdAt: Date;
  updatedAt: Date;
}

export interface Attendance {
  id: string;
  userId: string;
  clientId?: string;
  client?: Client;
  checkInTime: Date;
  checkOutTime?: Date;
  type: AttendanceType;
  notes?: string;
  createdAt?: Date;
}

export interface Recommendation {
  id: string;
  userId: string;
  fitnessProfileId: string;
  recommendationText: string;
  activityPlan: string;
  dietPlan: string;
  status: RecommendationStatus;
  generatedAt: Date;
  approvedAt?: Date;
  approvedBy?: string;
  createdAt: Date;
  updatedAt: Date;
}

export interface FitnessGoal {
  id: string;
  userId: string;
  fitnessProfileId?: string;
  goalType: GoalType;
  title: string;
  description?: string;
  targetValue?: number;
  currentValue?: number;
  unit?: string;
  startDate: Date;
  targetDate?: Date;
  completedDate?: Date;
  status: GoalStatus;
  progress: number;
  priority: PriorityLevel;
  notes?: string;
  createdAt: Date;
  updatedAt: Date;
}

export interface Payment {
  id: string;
  clientId: string;
  client?: Client; // Made optional (was required)
  amount: number;
  currency: string;
  status: PaymentStatus;
  paymentMethod: PaymentMethod;
  dueDate: Date;
  paidAt?: Date;
  description: string;
}

export interface Notification {
  id: string;
  userId: string;
  title: string;
  message: string;
  type: NotificationType;
  read: boolean;
  createdAt: Date;
}

export interface Gym {
  id: string;
  name: string;
  location?: string;
  status: GymStatus;
  adminUserId: string;
}

export interface Invitation {
  id: string;
  inviterUserId: string;
  inviteeEmail: string;
  roleAssigned: UserRole;
  gymId: string;
  token: string;
  status: "sent" | "accepted" | "expired";
  expiresAt: Date;
  createdAt: Date;
}

export interface TrainerClient {
  id: string;
  trainerUserId: string;
  clientUserId: string;
  gymId: string;
  createdAt: Date;
}
