From 591b5d7b88710b16fde5f212c6592bd16da25c38 Mon Sep 17 00:00:00 2001 From: Achintha Isuru Date: Thu, 19 Mar 2026 16:44:54 -0400 Subject: [PATCH] feat: Enhance CancelledShift and PendingAssignment models with additional fields for client and pay details --- .../src/entities/shifts/cancelled_shift.dart | 56 +++++++++++++++++++ .../entities/shifts/pending_assignment.dart | 35 ++++++++++++ 2 files changed, 91 insertions(+) diff --git a/apps/mobile/packages/domain/lib/src/entities/shifts/cancelled_shift.dart b/apps/mobile/packages/domain/lib/src/entities/shifts/cancelled_shift.dart index d2cff728..99488dbc 100644 --- a/apps/mobile/packages/domain/lib/src/entities/shifts/cancelled_shift.dart +++ b/apps/mobile/packages/domain/lib/src/entities/shifts/cancelled_shift.dart @@ -15,6 +15,14 @@ class CancelledShift extends Equatable { required this.location, required this.date, this.cancellationReason, + this.roleName, + this.clientName, + this.startTime, + this.endTime, + this.hourlyRateCents, + this.hourlyRate, + this.totalRateCents, + this.totalRate, }); /// Deserialises from the V2 API JSON response. @@ -26,6 +34,14 @@ class CancelledShift extends Equatable { location: json['location'] as String? ?? '', date: parseUtcToLocal(json['date'] as String), cancellationReason: json['cancellationReason'] as String?, + roleName: json['roleName'] as String?, + clientName: json['clientName'] as String?, + startTime: tryParseUtcToLocal(json['startTime'] as String?), + endTime: tryParseUtcToLocal(json['endTime'] as String?), + hourlyRateCents: json['hourlyRateCents'] as int?, + hourlyRate: (json['hourlyRate'] as num?)?.toDouble(), + totalRateCents: json['totalRateCents'] as int?, + totalRate: (json['totalRate'] as num?)?.toDouble(), ); } @@ -47,6 +63,30 @@ class CancelledShift extends Equatable { /// Reason for cancellation, from assignment metadata. final String? cancellationReason; + /// Display name of the role. + final String? roleName; + + /// Name of the client/business. + final String? clientName; + + /// Scheduled start time. + final DateTime? startTime; + + /// Scheduled end time. + final DateTime? endTime; + + /// Pay rate in cents per hour. + final int? hourlyRateCents; + + /// Pay rate in dollars per hour. + final double? hourlyRate; + + /// Total pay for this shift in cents. + final int? totalRateCents; + + /// Total pay for this shift in dollars. + final double? totalRate; + /// Serialises to JSON. Map toJson() { return { @@ -56,6 +96,14 @@ class CancelledShift extends Equatable { 'location': location, 'date': date.toIso8601String(), 'cancellationReason': cancellationReason, + 'roleName': roleName, + 'clientName': clientName, + 'startTime': startTime?.toIso8601String(), + 'endTime': endTime?.toIso8601String(), + 'hourlyRateCents': hourlyRateCents, + 'hourlyRate': hourlyRate, + 'totalRateCents': totalRateCents, + 'totalRate': totalRate, }; } @@ -67,5 +115,13 @@ class CancelledShift extends Equatable { location, date, cancellationReason, + roleName, + clientName, + startTime, + endTime, + hourlyRateCents, + hourlyRate, + totalRateCents, + totalRate, ]; } diff --git a/apps/mobile/packages/domain/lib/src/entities/shifts/pending_assignment.dart b/apps/mobile/packages/domain/lib/src/entities/shifts/pending_assignment.dart index c96c5810..bf89944f 100644 --- a/apps/mobile/packages/domain/lib/src/entities/shifts/pending_assignment.dart +++ b/apps/mobile/packages/domain/lib/src/entities/shifts/pending_assignment.dart @@ -17,6 +17,11 @@ class PendingAssignment extends Equatable { required this.endTime, required this.location, required this.responseDeadline, + this.clientName, + this.hourlyRateCents, + this.hourlyRate, + this.totalRateCents, + this.totalRate, }); /// Deserialises from the V2 API JSON response. @@ -30,6 +35,11 @@ class PendingAssignment extends Equatable { endTime: parseUtcToLocal(json['endTime'] as String), location: json['location'] as String? ?? '', responseDeadline: parseUtcToLocal(json['responseDeadline'] as String), + clientName: json['clientName'] as String?, + hourlyRateCents: json['hourlyRateCents'] as int?, + hourlyRate: (json['hourlyRate'] as num?)?.toDouble(), + totalRateCents: json['totalRateCents'] as int?, + totalRate: (json['totalRate'] as num?)?.toDouble(), ); } @@ -57,6 +67,21 @@ class PendingAssignment extends Equatable { /// Deadline by which the worker must respond. final DateTime responseDeadline; + /// Name of the client/business. + final String? clientName; + + /// Pay rate in cents per hour. + final int? hourlyRateCents; + + /// Pay rate in dollars per hour. + final double? hourlyRate; + + /// Total pay for this shift in cents. + final int? totalRateCents; + + /// Total pay for this shift in dollars. + final double? totalRate; + /// Serialises to JSON. Map toJson() { return { @@ -68,6 +93,11 @@ class PendingAssignment extends Equatable { 'endTime': endTime.toIso8601String(), 'location': location, 'responseDeadline': responseDeadline.toIso8601String(), + 'clientName': clientName, + 'hourlyRateCents': hourlyRateCents, + 'hourlyRate': hourlyRate, + 'totalRateCents': totalRateCents, + 'totalRate': totalRate, }; } @@ -81,5 +111,10 @@ class PendingAssignment extends Equatable { endTime, location, responseDeadline, + clientName, + hourlyRateCents, + hourlyRate, + totalRateCents, + totalRate, ]; }