feat: Enhance CancelledShift and PendingAssignment models with additional fields for client and pay details

This commit is contained in:
Achintha Isuru
2026-03-19 16:44:54 -04:00
parent a544b051cc
commit 591b5d7b88
2 changed files with 91 additions and 0 deletions

View File

@@ -15,6 +15,14 @@ class CancelledShift extends Equatable {
required this.location, required this.location,
required this.date, required this.date,
this.cancellationReason, 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. /// Deserialises from the V2 API JSON response.
@@ -26,6 +34,14 @@ class CancelledShift extends Equatable {
location: json['location'] as String? ?? '', location: json['location'] as String? ?? '',
date: parseUtcToLocal(json['date'] as String), date: parseUtcToLocal(json['date'] as String),
cancellationReason: json['cancellationReason'] 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. /// Reason for cancellation, from assignment metadata.
final String? cancellationReason; 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. /// Serialises to JSON.
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return <String, dynamic>{ return <String, dynamic>{
@@ -56,6 +96,14 @@ class CancelledShift extends Equatable {
'location': location, 'location': location,
'date': date.toIso8601String(), 'date': date.toIso8601String(),
'cancellationReason': cancellationReason, '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, location,
date, date,
cancellationReason, cancellationReason,
roleName,
clientName,
startTime,
endTime,
hourlyRateCents,
hourlyRate,
totalRateCents,
totalRate,
]; ];
} }

View File

@@ -17,6 +17,11 @@ class PendingAssignment extends Equatable {
required this.endTime, required this.endTime,
required this.location, required this.location,
required this.responseDeadline, required this.responseDeadline,
this.clientName,
this.hourlyRateCents,
this.hourlyRate,
this.totalRateCents,
this.totalRate,
}); });
/// Deserialises from the V2 API JSON response. /// Deserialises from the V2 API JSON response.
@@ -30,6 +35,11 @@ class PendingAssignment extends Equatable {
endTime: parseUtcToLocal(json['endTime'] as String), endTime: parseUtcToLocal(json['endTime'] as String),
location: json['location'] as String? ?? '', location: json['location'] as String? ?? '',
responseDeadline: parseUtcToLocal(json['responseDeadline'] 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. /// Deadline by which the worker must respond.
final DateTime responseDeadline; 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. /// Serialises to JSON.
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return <String, dynamic>{ return <String, dynamic>{
@@ -68,6 +93,11 @@ class PendingAssignment extends Equatable {
'endTime': endTime.toIso8601String(), 'endTime': endTime.toIso8601String(),
'location': location, 'location': location,
'responseDeadline': responseDeadline.toIso8601String(), 'responseDeadline': responseDeadline.toIso8601String(),
'clientName': clientName,
'hourlyRateCents': hourlyRateCents,
'hourlyRate': hourlyRate,
'totalRateCents': totalRateCents,
'totalRate': totalRate,
}; };
} }
@@ -81,5 +111,10 @@ class PendingAssignment extends Equatable {
endTime, endTime,
location, location,
responseDeadline, responseDeadline,
clientName,
hourlyRateCents,
hourlyRate,
totalRateCents,
totalRate,
]; ];
} }