Implement Asia/Manila Time Zone
Handled saving of Relievers
This commit is contained in:
@@ -1,19 +1,69 @@
|
||||
class GeofenceConfig {
|
||||
GeofenceConfig({
|
||||
required this.lat,
|
||||
required this.lng,
|
||||
required this.radiusMeters,
|
||||
});
|
||||
GeofenceConfig({this.lat, this.lng, this.radiusMeters, this.polygon});
|
||||
|
||||
final double? lat;
|
||||
final double? lng;
|
||||
final double? radiusMeters;
|
||||
final List<GeofencePoint>? polygon;
|
||||
|
||||
bool get hasPolygon => polygon?.isNotEmpty == true;
|
||||
bool get hasCircle =>
|
||||
lat != null && lng != null && radiusMeters != null && radiusMeters! > 0;
|
||||
|
||||
bool containsPolygon(double pointLat, double pointLng) {
|
||||
final points = polygon;
|
||||
if (points == null || points.isEmpty) return false;
|
||||
var inside = false;
|
||||
for (var i = 0, j = points.length - 1; i < points.length; j = i++) {
|
||||
final xi = points[i].lng;
|
||||
final yi = points[i].lat;
|
||||
final xj = points[j].lng;
|
||||
final yj = points[j].lat;
|
||||
|
||||
final intersects =
|
||||
((yi > pointLat) != (yj > pointLat)) &&
|
||||
(pointLng < (xj - xi) * (pointLat - yi) / (yj - yi) + xi);
|
||||
if (intersects) {
|
||||
inside = !inside;
|
||||
}
|
||||
}
|
||||
return inside;
|
||||
}
|
||||
|
||||
factory GeofenceConfig.fromJson(Map<String, dynamic> json) {
|
||||
final rawPolygon = json['polygon'] ?? json['points'];
|
||||
final polygonPoints = <GeofencePoint>[];
|
||||
if (rawPolygon is List) {
|
||||
for (final entry in rawPolygon) {
|
||||
if (entry is Map<String, dynamic>) {
|
||||
polygonPoints.add(GeofencePoint.fromJson(entry));
|
||||
} else if (entry is Map) {
|
||||
polygonPoints.add(
|
||||
GeofencePoint.fromJson(Map<String, dynamic>.from(entry)),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return GeofenceConfig(
|
||||
lat: (json['lat'] as num?)?.toDouble(),
|
||||
lng: (json['lng'] as num?)?.toDouble(),
|
||||
radiusMeters: (json['radius_m'] as num?)?.toDouble(),
|
||||
polygon: polygonPoints.isEmpty ? null : polygonPoints,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class GeofencePoint {
|
||||
const GeofencePoint({required this.lat, required this.lng});
|
||||
|
||||
final double lat;
|
||||
final double lng;
|
||||
final double radiusMeters;
|
||||
|
||||
factory GeofenceConfig.fromJson(Map<String, dynamic> json) {
|
||||
return GeofenceConfig(
|
||||
factory GeofencePoint.fromJson(Map<String, dynamic> json) {
|
||||
return GeofencePoint(
|
||||
lat: (json['lat'] as num).toDouble(),
|
||||
lng: (json['lng'] as num).toDouble(),
|
||||
radiusMeters: (json['radius_m'] as num).toDouble(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import '../utils/app_time.dart';
|
||||
|
||||
class NotificationItem {
|
||||
NotificationItem({
|
||||
required this.id,
|
||||
@@ -32,10 +34,10 @@ class NotificationItem {
|
||||
taskId: map['task_id'] as String?,
|
||||
messageId: map['message_id'] as int?,
|
||||
type: map['type'] as String? ?? 'mention',
|
||||
createdAt: DateTime.parse(map['created_at'] as String),
|
||||
createdAt: AppTime.parse(map['created_at'] as String),
|
||||
readAt: map['read_at'] == null
|
||||
? null
|
||||
: DateTime.parse(map['read_at'] as String),
|
||||
: AppTime.parse(map['read_at'] as String),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import '../utils/app_time.dart';
|
||||
|
||||
class SwapRequest {
|
||||
SwapRequest({
|
||||
required this.id,
|
||||
@@ -26,10 +28,10 @@ class SwapRequest {
|
||||
recipientId: map['recipient_id'] as String,
|
||||
shiftId: map['shift_id'] as String,
|
||||
status: map['status'] as String? ?? 'pending',
|
||||
createdAt: DateTime.parse(map['created_at'] as String),
|
||||
createdAt: AppTime.parse(map['created_at'] as String),
|
||||
updatedAt: map['updated_at'] == null
|
||||
? null
|
||||
: DateTime.parse(map['updated_at'] as String),
|
||||
: AppTime.parse(map['updated_at'] as String),
|
||||
approvedBy: map['approved_by'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import '../utils/app_time.dart';
|
||||
|
||||
class Task {
|
||||
Task({
|
||||
required this.id,
|
||||
@@ -37,14 +39,14 @@ class Task {
|
||||
status: map['status'] as String? ?? 'queued',
|
||||
priority: map['priority'] as int? ?? 1,
|
||||
queueOrder: map['queue_order'] as int?,
|
||||
createdAt: DateTime.parse(map['created_at'] as String),
|
||||
createdAt: AppTime.parse(map['created_at'] as String),
|
||||
creatorId: map['creator_id'] as String?,
|
||||
startedAt: map['started_at'] == null
|
||||
? null
|
||||
: DateTime.parse(map['started_at'] as String),
|
||||
: AppTime.parse(map['started_at'] as String),
|
||||
completedAt: map['completed_at'] == null
|
||||
? null
|
||||
: DateTime.parse(map['completed_at'] as String),
|
||||
: AppTime.parse(map['completed_at'] as String),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import '../utils/app_time.dart';
|
||||
|
||||
class TaskAssignment {
|
||||
TaskAssignment({
|
||||
required this.taskId,
|
||||
@@ -13,7 +15,7 @@ class TaskAssignment {
|
||||
return TaskAssignment(
|
||||
taskId: map['task_id'] as String,
|
||||
userId: map['user_id'] as String,
|
||||
createdAt: DateTime.parse(map['created_at'] as String),
|
||||
createdAt: AppTime.parse(map['created_at'] as String),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import '../utils/app_time.dart';
|
||||
|
||||
class Ticket {
|
||||
Ticket({
|
||||
required this.id,
|
||||
@@ -30,17 +32,17 @@ class Ticket {
|
||||
description: map['description'] as String? ?? '',
|
||||
officeId: map['office_id'] as String? ?? '',
|
||||
status: map['status'] as String? ?? 'pending',
|
||||
createdAt: DateTime.parse(map['created_at'] as String),
|
||||
createdAt: AppTime.parse(map['created_at'] as String),
|
||||
creatorId: map['creator_id'] as String?,
|
||||
respondedAt: map['responded_at'] == null
|
||||
? null
|
||||
: DateTime.parse(map['responded_at'] as String),
|
||||
: AppTime.parse(map['responded_at'] as String),
|
||||
promotedAt: map['promoted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(map['promoted_at'] as String),
|
||||
: AppTime.parse(map['promoted_at'] as String),
|
||||
closedAt: map['closed_at'] == null
|
||||
? null
|
||||
: DateTime.parse(map['closed_at'] as String),
|
||||
: AppTime.parse(map['closed_at'] as String),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import '../utils/app_time.dart';
|
||||
|
||||
class TicketMessage {
|
||||
TicketMessage({
|
||||
required this.id,
|
||||
@@ -22,7 +24,7 @@ class TicketMessage {
|
||||
taskId: map['task_id'] as String?,
|
||||
senderId: map['sender_id'] as String?,
|
||||
content: map['content'] as String? ?? '',
|
||||
createdAt: DateTime.parse(map['created_at'] as String),
|
||||
createdAt: AppTime.parse(map['created_at'] as String),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user