import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:fcs/domain/entities/package.dart'; class Pickup { String? id; DateTime? pickupDate; String? fromTime; String? toTime; //for consignee String? userID; String? userName; String? userPhoneNumber; String? staffId; String? staffName; String? staffPhoneNumber; //for shipper String? fcsID; String? shipperName; String? shipperPhoneNumber; String? status; // for complete String? completeRemark; List photoUrls; List packages; Pickup( {this.id, this.userID, this.userName, this.userPhoneNumber, this.staffId, this.staffName, this.staffPhoneNumber, this.pickupDate, this.fromTime, this.toTime, this.fcsID, this.shipperName, this.shipperPhoneNumber, this.status, this.packages = const [], this.photoUrls = const []}); @override bool operator ==(Object other) => other is Pickup && other.id == id; @override int get hashCode => id.hashCode; bool isChangedForEdit(Pickup Pickup) { return Pickup.userID != this.userID || Pickup.fcsID != this.fcsID || Pickup.packages != this.packages; } factory Pickup.fromMap(Map map, String id) { var _pickupDate = (map['pickup_date'] as Timestamp); return Pickup( id: id, pickupDate: _pickupDate.toDate(), fromTime: map['from_time'], toTime: map['to_time'], staffId: map['staff_id'], staffName: map['staff_name'], staffPhoneNumber: map['staff_phone_number'], userID: map['user_id'], userName: map['user_name'], userPhoneNumber: map['user_phone_number'], status: map['status']); } Map toMap() { return { "id": id, "pickup_date": pickupDate?.toUtc().toIso8601String(), 'from_time': fromTime, 'to_time': toTime, 'staff_id': staffId, 'staff_name': staffName, "staff_phone_number": staffPhoneNumber, 'user_id': userID, 'user_name': userName, 'user_phone_number': userPhoneNumber, 'status': status, }; } Map toMapForComplete() { return { "id": id, "complete_remark": completeRemark, 'photo_urls': photoUrls ?? [], }; } @override String toString() { return 'Pickup{id: $id}'; } }