class UserActivity {
  int id;
  String porOrgacode;
  String cmpCustcode;
  DateTime date;
  String channel;
  String deviceName;
  String activity;

  UserActivity({
    required this.id,
    required this.porOrgacode,
    required this.cmpCustcode,
    required this.date,
    required this.channel,
    required this.deviceName,
    required this.activity,
  });

  Map<String, dynamic> toMap() {
    return {
      'id': id,
      'porOrgacode': porOrgacode,
      'cmpCustcode': cmpCustcode,
      'date': date.toIso8601String(),
      'channel': channel,
      'deviceName': deviceName,
      'activity': activity,
    };
  }

  factory UserActivity.fromMap(Map<String, dynamic> map) {
    return UserActivity(
      id: map['id'] ?? '',
      porOrgacode: map['porOrgacode'] ?? '',
      cmpCustcode: map['cmpCustcode'] ?? '',
      date: DateTime.parse(map['date'] ?? ''),
      channel: map['channel'] ?? '01',
      deviceName: map['deviceName'] ?? '',
      activity: map['activity'] ?? '',
    );
  }

  @override
  String toString() {
    return 'LoginActivity{id: $id, porOrgacode: $porOrgacode, cmpCustcode: $cmpCustcode, date: $date, channel: $channel, deviceName: $deviceName, activity: $activity}';
  }
}
