45 lines
1.3 KiB
Swift
45 lines
1.3 KiB
Swift
//
|
|
// EmployeeCellViewModel.swift
|
|
// EmployeeDirectory
|
|
//
|
|
// Created by Matt Bruce on 1/20/25.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
|
|
@MainActor
|
|
public class EmployeeCellViewModel: ObservableObject {
|
|
private let employee: Employee
|
|
|
|
public private(set) var uuid: String
|
|
public private(set) var fullName: String
|
|
public private(set) var phoneNumber: String?
|
|
public private(set) var emailAddress: String
|
|
public private(set) var biography: String?
|
|
public private(set) var team: String
|
|
public private(set) var employeeType: String
|
|
@Published public private(set) var smallPhoto: UIImage?
|
|
|
|
public init(employee: Employee) {
|
|
self.employee = employee
|
|
|
|
// Initialize properties
|
|
self.uuid = employee.uuid.uuidString
|
|
self.fullName = employee.fullName
|
|
self.phoneNumber = employee.phoneNumber?.formatUSNumber()
|
|
self.emailAddress = employee.emailAddress
|
|
self.biography = employee.biography
|
|
self.team = employee.team
|
|
self.employeeType = employee.employeeType.description
|
|
|
|
if let endpoint = employee.photoURLSmall {
|
|
Task{
|
|
if let smallPhotoURL = URL(string: endpoint) {
|
|
smallPhoto = await ImageCacheService.shared.loadImage(from: smallPhotoURL)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|