- Add profile endpoints (getProfile/updateProfile) to APIService - Fix beacon dwell time: 5 → 30 samples to match Android (~3s) - Make chat WebSocket dev-aware (uses IS_DEV flag) - Add activeTaskCount field to Employment model - Fix categoryName: remove incorrect fallback to taskTypeName Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
37 lines
1.4 KiB
Swift
37 lines
1.4 KiB
Swift
import Foundation
|
|
|
|
struct Employment: Identifiable {
|
|
let employeeId: Int
|
|
let businessId: Int
|
|
let businessName: String
|
|
let businessAddress: String
|
|
let businessCity: String
|
|
let employeeStatusId: Int
|
|
let pendingTaskCount: Int
|
|
let activeTaskCount: Int
|
|
|
|
var id: Int { employeeId }
|
|
|
|
/// Decode directly from a [String: Any] dictionary (matches Flutter's fromJson)
|
|
init(json: [String: Any]) {
|
|
employeeId = WorkTask.parseInt(json["EmployeeID"]) ?? 0
|
|
businessId = WorkTask.parseInt(json["BusinessID"]) ?? 0
|
|
// Server returns "Name" not "BusinessName"
|
|
businessName = (json["Name"] as? String) ?? (json["BusinessName"] as? String) ?? ""
|
|
businessAddress = (json["Address"] as? String) ?? (json["BusinessAddress"] as? String) ?? ""
|
|
businessCity = (json["City"] as? String) ?? (json["BusinessCity"] as? String) ?? ""
|
|
// Match Flutter: read EmployeeStatusID first (server sends StatusID, which may differ)
|
|
employeeStatusId = WorkTask.parseInt(json["EmployeeStatusID"] ?? json["StatusID"]) ?? 0
|
|
pendingTaskCount = WorkTask.parseInt(json["PendingTaskCount"]) ?? 0
|
|
activeTaskCount = WorkTask.parseInt(json["ActiveTaskCount"]) ?? 0
|
|
}
|
|
|
|
var statusName: String {
|
|
switch employeeStatusId {
|
|
case 0: return "Pending"
|
|
case 1: return "Active"
|
|
case 2: return "Inactive"
|
|
default: return "Unknown"
|
|
}
|
|
}
|
|
}
|