import UIKit

class EventCell: UITableViewCell {
    @IBOutlet weak var address: UILabel!
    @IBOutlet weak var date: UILabel!
    
    let dateFormatter = DateFormatter()
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        self.dateFormatter.dateStyle = .short
        self.dateFormatter.timeStyle = .short
    }
    
    func configure(with event: VehicleEvent) {
        if let addressString = event.address {
            self.address.text = addressString
        } else {
            self.address.text = "Lat: \(event.latitude), Lon: \(event.longitude)"
        }
        
        let date = Date(timeIntervalSince1970: event.date)
        self.date.text = self.dateFormatter.string(from: date)
    }
}
