Implement Asia/Manila Time Zone
Handled saving of Relievers
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import '../utils/app_time.dart';
|
||||
|
||||
class DutySchedule {
|
||||
DutySchedule({
|
||||
required this.id,
|
||||
@@ -9,6 +11,7 @@ class DutySchedule {
|
||||
required this.createdAt,
|
||||
required this.checkInAt,
|
||||
required this.checkInLocation,
|
||||
required this.relieverIds,
|
||||
});
|
||||
|
||||
final String id;
|
||||
@@ -20,20 +23,30 @@ class DutySchedule {
|
||||
final DateTime createdAt;
|
||||
final DateTime? checkInAt;
|
||||
final Object? checkInLocation;
|
||||
final List<String> relieverIds;
|
||||
|
||||
factory DutySchedule.fromMap(Map<String, dynamic> map) {
|
||||
final relieversRaw = map['reliever_ids'];
|
||||
final relievers = relieversRaw is List
|
||||
? relieversRaw
|
||||
.where((e) => e != null)
|
||||
.map((entry) => entry.toString())
|
||||
.where((s) => s.isNotEmpty)
|
||||
.toList()
|
||||
: <String>[];
|
||||
return DutySchedule(
|
||||
id: map['id'] as String,
|
||||
userId: map['user_id'] as String,
|
||||
shiftType: map['shift_type'] as String? ?? 'normal',
|
||||
startTime: DateTime.parse(map['start_time'] as String),
|
||||
endTime: DateTime.parse(map['end_time'] as String),
|
||||
startTime: AppTime.parse(map['start_time'] as String),
|
||||
endTime: AppTime.parse(map['end_time'] as String),
|
||||
status: map['status'] as String? ?? 'scheduled',
|
||||
createdAt: DateTime.parse(map['created_at'] as String),
|
||||
createdAt: AppTime.parse(map['created_at'] as String),
|
||||
checkInAt: map['check_in_at'] == null
|
||||
? null
|
||||
: DateTime.parse(map['check_in_at'] as String),
|
||||
: AppTime.parse(map['check_in_at'] as String),
|
||||
checkInLocation: map['check_in_location'],
|
||||
relieverIds: relievers,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user