export type UserType = "worker" | "contractor";

export type Availability = "full-time" | "casual" | "weekends" | "flexible";

export type RateType = "hourly" | "daily";

export type JobStatus = "draft" | "active" | "filled" | "closed";

export type MatchStatus =
  | "suggested"
  | "applied"
  | "accepted"
  | "rejected"
  | "hired";

export type ActionStatus = "pending" | "accepted" | "rejected";

export type PaymentStatus = "pending" | "charged" | "refunded";

export type NotificationType = "match" | "hire_request" | "hire_confirmed" | "rating" | "job_posted" | "system";

export interface Profile {
  id: string;
  type: UserType;
  name: string | null;
  phone: string | null;
  email: string | null;
  avatar_url: string | null;
  /** 
   * Location as { lat, lng } object
   * Note: Database stores this as PostgreSQL point type
   * Use postgresPointToJson() when reading from DB
   * Use jsonToPostgresPoint() when writing to DB
   */
  location: { lat: number; lng: number } | null;
  suburb: string | null;
  verified: boolean;
  onboarding_completed: boolean;
  created_at: string;
  updated_at: string;
  ai_generated: boolean;
}

export interface Company {
  id: string;
  profile_id: string;
  name: string;
  abn: string | null;
  address: string | null;
  industry: string | null;
  size: string | null;
  website: string | null;
  logo_url: string | null;
  ai_research: Record<string, unknown> | null;
  created_at: string;
  updated_at: string;
}

export interface WorkerProfile {
  id: string;
  profile_id: string;
  trades: string[];
  experience_years: number | null;
  certifications: string[];
  white_card_number: string | null;
  white_card_verified: boolean;
  availability: Availability | null;
  languages: string[];
  bio: string | null;
  voice_note_url: string | null;
  ai_extracted: Record<string, unknown> | null;
  created_at: string;
  updated_at: string;
}

export interface Job {
  id: string;
  company_id: string;
  title: string;
  description: string | null;
  trade: string;
  /** 
   * Location as { lat, lng } object
   * Note: Database stores this as PostgreSQL point type
   * Use postgresPointToJson() when reading from DB
   * Use jsonToPostgresPoint() when writing to DB
   */
  location: { lat: number; lng: number } | null;
  suburb: string | null;
  site_address: string | null;
  rate_min: number | null;
  rate_max: number | null;
  rate_type: RateType;
  start_date: string | null;
  duration: string | null;
  workers_needed: number;
  certifications_required: string[];
  status: JobStatus;
  ai_generated: boolean;
  created_at: string;
  updated_at: string;
}

export interface Match {
  id: string;
  job_id: string;
  worker_id: string;
  status: MatchStatus;
  match_score: number | null;
  ai_summary: string | null;
  contractor_action: ActionStatus;
  worker_action: ActionStatus;
  hired_at: string | null;
  fee_charged: boolean;
  created_at: string;
  updated_at: string;
}

export interface Rating {
  id: string;
  match_id: string;
  from_id: string;
  to_id: string;
  score: number;
  comment: string | null;
  created_at: string;
}

export interface Payment {
  id: string;
  match_id: string;
  company_id: string;
  amount: number;
  status: PaymentStatus;
  stripe_payment_id: string | null;
  created_at: string;
}

export interface Notification {
  id: string;
  profile_id: string;
  type: NotificationType;
  title: string;
  body: string | null;
  data: Record<string, unknown> | null;
  read: boolean;
  created_at: string;
}
