From 38007d32bcf758052a86d65ccd8b406760b874ff Mon Sep 17 00:00:00 2001 From: Achintha Isuru Date: Wed, 4 Mar 2026 13:37:42 -0500 Subject: [PATCH] refactor: Enhance StaffPayment model and PaymentHistoryItem widget with shift details --- .../src/entities/financial/staff_payment.dart | 26 ++++++++++++++++++- .../payments_repository_impl.dart | 16 ++++++++++++ .../src/presentation/pages/payments_page.dart | 14 +++++----- .../widgets/payment_history_item.dart | 6 ++--- 4 files changed, 50 insertions(+), 12 deletions(-) diff --git a/apps/mobile/packages/domain/lib/src/entities/financial/staff_payment.dart b/apps/mobile/packages/domain/lib/src/entities/financial/staff_payment.dart index d6126de8..75cd8d8e 100644 --- a/apps/mobile/packages/domain/lib/src/entities/financial/staff_payment.dart +++ b/apps/mobile/packages/domain/lib/src/entities/financial/staff_payment.dart @@ -28,6 +28,12 @@ class StaffPayment extends Equatable { required this.amount, required this.status, this.paidAt, + this.shiftTitle, + this.shiftLocation, + this.locationAddress, + this.hoursWorked, + this.hourlyRate, + this.workedTime, }); /// Unique identifier. final String id; @@ -47,6 +53,24 @@ class StaffPayment extends Equatable { /// When the payment was successfully processed. final DateTime? paidAt; + /// Title of the shift worked. + final String? shiftTitle; + + /// Location/hub name of the shift. + final String? shiftLocation; + + /// Address of the shift location. + final String? locationAddress; + + /// Number of hours worked. + final double? hoursWorked; + + /// Hourly rate for the shift. + final double? hourlyRate; + + /// Work session duration or status. + final String? workedTime; + @override - List get props => [id, staffId, assignmentId, amount, status, paidAt]; + List get props => [id, staffId, assignmentId, amount, status, paidAt, shiftTitle, shiftLocation, locationAddress, hoursWorked, hourlyRate, workedTime]; } \ No newline at end of file diff --git a/apps/mobile/packages/features/staff/payments/lib/src/data/repositories/payments_repository_impl.dart b/apps/mobile/packages/features/staff/payments/lib/src/data/repositories/payments_repository_impl.dart index 726a84b1..3c701b36 100644 --- a/apps/mobile/packages/features/staff/payments/lib/src/data/repositories/payments_repository_impl.dart +++ b/apps/mobile/packages/features/staff/payments/lib/src/data/repositories/payments_repository_impl.dart @@ -67,6 +67,16 @@ class PaymentsRepositoryImpl .execute(); return response.data.recentPayments.map((dc.ListRecentPaymentsByStaffIdRecentPayments payment) { + // Extract shift details from nested application structure + final String? shiftTitle = payment.application.shiftRole.shift.title; + final String? locationAddress = payment.application.shiftRole.shift.locationAddress; + final double? hoursWorked = payment.application.shiftRole.hours; + final double? hourlyRate = payment.application.shiftRole.role.costPerHour; + // Extract hub details from order + final String? locationHub = payment.invoice.order.teamHub.hubName; + final String? hubAddress = payment.invoice.order.teamHub.address; + final String? shiftLocation = locationAddress ?? hubAddress; + return StaffPayment( id: payment.id, staffId: payment.staffId, @@ -74,6 +84,12 @@ class PaymentsRepositoryImpl amount: payment.invoice.amount, status: PaymentAdapter.toPaymentStatus(payment.status?.stringValue ?? 'UNKNOWN'), paidAt: _service.toDateTime(payment.invoice.issueDate), + shiftTitle: shiftTitle, + shiftLocation: locationHub, + locationAddress: shiftLocation, + hoursWorked: hoursWorked, + hourlyRate: hourlyRate, + workedTime: payment.workedTime, ); }).toList(); }); diff --git a/apps/mobile/packages/features/staff/payments/lib/src/presentation/pages/payments_page.dart b/apps/mobile/packages/features/staff/payments/lib/src/presentation/pages/payments_page.dart index 3de923e0..b1ff94f3 100644 --- a/apps/mobile/packages/features/staff/payments/lib/src/presentation/pages/payments_page.dart +++ b/apps/mobile/packages/features/staff/payments/lib/src/presentation/pages/payments_page.dart @@ -1,5 +1,4 @@ import 'package:design_system/design_system.dart'; -import 'package:krow_core/core.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_modular/flutter_modular.dart'; @@ -10,7 +9,6 @@ import '../blocs/payments/payments_bloc.dart'; import '../blocs/payments/payments_event.dart'; import '../blocs/payments/payments_state.dart'; import '../widgets/payment_stats_card.dart'; -import '../widgets/pending_pay_card.dart'; import '../widgets/payment_history_item.dart'; import '../widgets/earnings_graph.dart'; @@ -191,16 +189,16 @@ class _PaymentsPageState extends State { bottom: UiConstants.space2), child: PaymentHistoryItem( amount: payment.amount, - title: "Shift Payment", - location: "Varies", - address: "Payment ID: ${payment.id}", + title: payment.shiftTitle ?? "Shift Payment", + location: payment.shiftLocation ?? "Varies", + address: payment.locationAddress ?? payment.id, date: payment.paidAt != null ? DateFormat('E, MMM d') .format(payment.paidAt!) : 'Pending', - workedTime: "Completed", - hours: 0, - rate: 0.0, + workedTime: payment.workedTime ?? "Completed", + hours: (payment.hoursWorked ?? 0).toInt(), + rate: payment.hourlyRate ?? 0.0, status: payment.status.name.toUpperCase(), ), ); diff --git a/apps/mobile/packages/features/staff/payments/lib/src/presentation/widgets/payment_history_item.dart b/apps/mobile/packages/features/staff/payments/lib/src/presentation/widgets/payment_history_item.dart index 99dba385..44fe3304 100644 --- a/apps/mobile/packages/features/staff/payments/lib/src/presentation/widgets/payment_history_item.dart +++ b/apps/mobile/packages/features/staff/payments/lib/src/presentation/widgets/payment_history_item.dart @@ -71,7 +71,7 @@ class PaymentHistoryItem extends StatelessWidget { borderRadius: BorderRadius.circular(UiConstants.radiusBase), ), child: const Icon( - UiIcons.chart, + UiIcons.dollar, color: UiColors.mutedForeground, size: 24, ), @@ -92,7 +92,7 @@ class PaymentHistoryItem extends StatelessWidget { children: [ Text( title, - style: UiTypography.body2b.textPrimary, + style: UiTypography.body2m, ), Text( location, @@ -106,7 +106,7 @@ class PaymentHistoryItem extends StatelessWidget { children: [ Text( "\$${amount.toStringAsFixed(0)}", - style: UiTypography.headline4m.textPrimary, + style: UiTypography.headline4b, ), Text( "\$${rate.toStringAsFixed(0)}/hr ยท ${hours}h",