From 1e4c8982a504befdd0334c32f18f73033f21f3f7 Mon Sep 17 00:00:00 2001 From: Achintha Isuru Date: Thu, 19 Mar 2026 23:55:57 -0400 Subject: [PATCH] feat: Add additional fields to OrderItem and update cost calculation in ViewOrderCard --- .../lib/src/entities/orders/order_item.dart | 70 +++++++++++++++++++ .../presentation/widgets/view_order_card.dart | 4 +- 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/apps/mobile/packages/domain/lib/src/entities/orders/order_item.dart b/apps/mobile/packages/domain/lib/src/entities/orders/order_item.dart index dfcd6072..b064f083 100644 --- a/apps/mobile/packages/domain/lib/src/entities/orders/order_item.dart +++ b/apps/mobile/packages/domain/lib/src/entities/orders/order_item.dart @@ -26,6 +26,16 @@ class OrderItem extends Equatable { this.locationName, required this.status, this.workers = const [], + this.eventName = '', + this.clientName = '', + this.hourlyRate = 0.0, + this.hours = 0.0, + this.totalValue = 0.0, + this.locationAddress, + this.startTime, + this.endTime, + this.hubManagerId, + this.hubManagerName, }); /// Deserialises an [OrderItem] from a V2 API JSON map. @@ -53,6 +63,16 @@ class OrderItem extends Equatable { locationName: json['locationName'] as String?, status: ShiftStatus.fromJson(json['status'] as String?), workers: workersList, + eventName: json['eventName'] as String? ?? '', + clientName: json['clientName'] as String? ?? '', + hourlyRate: (json['hourlyRate'] as num?)?.toDouble() ?? 0.0, + hours: (json['hours'] as num?)?.toDouble() ?? 0.0, + totalValue: (json['totalValue'] as num?)?.toDouble() ?? 0.0, + locationAddress: json['locationAddress'] as String?, + startTime: json['startTime'] as String?, + endTime: json['endTime'] as String?, + hubManagerId: json['hubManagerId'] as String?, + hubManagerName: json['hubManagerName'] as String?, ); } @@ -98,6 +118,36 @@ class OrderItem extends Equatable { /// Assigned workers for this line item. final List workers; + /// Event/order name. + final String eventName; + + /// Client/business name. + final String clientName; + + /// Billing rate in dollars per hour. + final double hourlyRate; + + /// Duration of the shift in fractional hours. + final double hours; + + /// Total cost in dollars (rate x workers x hours). + final double totalValue; + + /// Full street address of the location. + final String? locationAddress; + + /// Display start time string (HH:MM UTC). + final String? startTime; + + /// Display end time string (HH:MM UTC). + final String? endTime; + + /// Hub manager's business membership ID. + final String? hubManagerId; + + /// Hub manager's display name. + final String? hubManagerName; + /// Serialises this [OrderItem] to a JSON map. Map toJson() { return { @@ -115,6 +165,16 @@ class OrderItem extends Equatable { 'locationName': locationName, 'status': status.toJson(), 'workers': workers.map((AssignedWorkerSummary w) => w.toJson()).toList(), + 'eventName': eventName, + 'clientName': clientName, + 'hourlyRate': hourlyRate, + 'hours': hours, + 'totalValue': totalValue, + 'locationAddress': locationAddress, + 'startTime': startTime, + 'endTime': endTime, + 'hubManagerId': hubManagerId, + 'hubManagerName': hubManagerName, }; } @@ -134,5 +194,15 @@ class OrderItem extends Equatable { locationName, status, workers, + eventName, + clientName, + hourlyRate, + hours, + totalValue, + locationAddress, + startTime, + endTime, + hubManagerId, + hubManagerName, ]; } diff --git a/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_order_card.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_order_card.dart index 969aed43..d14a2f94 100644 --- a/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_order_card.dart +++ b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_order_card.dart @@ -123,7 +123,9 @@ class _ViewOrderCardState extends State { : 0; final double hours = _computeHours(order); - final double cost = order.totalCostCents / 100.0; + final double cost = order.totalValue > 0 + ? order.totalValue + : order.totalCostCents / 100.0; return Container( decoration: BoxDecoration(