import Foundation

struct LoginRequest: Encodable {
    let email: String
    let password: String
    let device_name: String
}

struct AuthResponse: Decodable {
    let token: String?
    let user: UserDTO
    let team: TeamDTO?
    let team_role: String?
}

struct UserDTO: Decodable {
    let id: Int
    let name: String
    let email: String
}

struct TeamDTO: Decodable {
    let id: Int
    let name: String
}

struct JobDTO: Decodable, Identifiable {
    let id: Int
    let title: String
    let status: String?
    let default_duration_minutes: Int?
}

struct JobsResponse: Decodable {
    let data: [JobDTO]
}

struct AppointmentDTO: Decodable, Identifiable {
    let id: Int
    let job_id: Int
    let starts_at: String
    let ends_at: String
    let status: String
    let notes: String?
    let job: JobDTO?
}

struct AppointmentsResponse: Decodable {
    let data: [AppointmentDTO]
}

struct CheckInRequest: Encodable {
    let latitude: Double
    let longitude: Double
}

struct CheckInResponse: Decodable {
    let appointment: AppointmentDTO?
}

struct SlotDTO: Decodable, Identifiable {
    var id: String { starts_at }
    let starts_at: String
    let ends_at: String
}

struct SlotsResponse: Decodable {
    let date: String
    let slots: [SlotDTO]
}

struct BookAppointmentRequest: Encodable {
    let starts_at: String
    let status: String

    init(startsAt: String) {
        self.starts_at = startsAt
        self.status = "scheduled"
    }
}
