export interface User {
  id: number;
  firstname: string;
  lastname: string;
  email: string;
  role: UserRole;
  is_active: boolean;
  avatar?: string;
  created_at: string;
  updated_at: string;
}

export interface userProfile {
  id: string;
  full_name: string;
  company_name: string;
  phone: string;
  role: UserRole;
  address: string;
  city: string;
  state: string;
  zip_code: string;
  hvac_system_type: string;
  hvac_system_age: string;
  email_verified: boolean;
  created_at: string;
  updated_at: string;
}

export interface UserSubscription {
  id: string;
  user_id: string;
  plan_id: string;
  status: "active" | "cancelled" | "expired" | "past_due";
  billing_cycle: "monthly" | "yearly";
  current_period_start: string;
  current_period_end: string;
  cancel_at_period_end: boolean;
  payment_method: string;
  external_subscription_id: string;
  created_at: string;
  updated_at: string;
}

export interface AuthResponse {
  user: User;
  access_token: string;
}

export interface LoginPayload {
  email: string;
  password: string;
}

export interface RegisterPayload {
  firstname: string;
  lastname: string;
  email: string;
  password: string;
  password_confirmation: string;
  role: "student" | "instructor";
}

export interface AuthState {
  user: User | null;
  token: string | null;
  loading: boolean;
  error: string | null;

  setUser: (user: User | null) => void;
  setToken: (token: string | null) => void;
  setLoading: (loading: boolean) => void;
  setError: (error: string | null) => void;

  logout: () => void;

  /** MUST BE A FUNCTION — NOT A BOOLEAN */
  isAuthenticated: () => boolean;
}

export type UserRole = "customer" | "admin" | "tech";

export interface User {
  id: string;
  name: string;
  email: string;
  role: UserRole;
}

export interface AuthState {
  user: User | null;
  token: string | null;
  loading: boolean;
  error: string | null;

  setUser: (user: User | null) => void;
  setToken: (token: string | null) => void;
  setLoading: (loading: boolean) => void;
  setError: (error: string | null) => void;

  logout: () => void;
  isAuthenticated: () => boolean;
}
