Merge pull request 'Dev_Manish_Bug' (#85) from Dev_Manish_Bug into main

Reviewed-on: #85
This commit is contained in:
vaibhav.surve 2025-11-27 05:31:48 +00:00
commit 84156167ea
5 changed files with 46 additions and 54 deletions

View File

@ -281,6 +281,7 @@ class PaymentRequestDetailController extends GetxController {
String? tdsPercentage, String? tdsPercentage,
}) async { }) async {
isLoading.value = true; isLoading.value = true;
try { try {
final success = await ApiService.updateExpensePaymentRequestStatusApi( final success = await ApiService.updateExpensePaymentRequestStatusApi(
paymentRequestId: _requestId, paymentRequestId: _requestId,
@ -295,25 +296,14 @@ class PaymentRequestDetailController extends GetxController {
); );
if (success) { if (success) {
showAppSnackbar( // Controller refreshes the data but does not show snackbars.
title: 'Success',
message: 'Payment submitted successfully',
type: SnackbarType.success);
await fetchPaymentRequestDetail(); await fetchPaymentRequestDetail();
paymentRequestController.fetchPaymentRequests(); paymentRequestController.fetchPaymentRequests();
} else {
showAppSnackbar(
title: 'Error',
message: 'Failed to update status. Please try again.',
type: SnackbarType.error);
} }
return success; return success;
} catch (e) { } catch (e) {
showAppSnackbar( // Controller returns false on error; UI will show the snackbar.
title: 'Error',
message: 'Something went wrong: $e',
type: SnackbarType.error);
return false; return false;
} finally { } finally {
isLoading.value = false; isLoading.value = false;

View File

@ -23,6 +23,7 @@ class AttendanceActionButton extends StatefulWidget {
} }
class _AttendanceActionButtonState extends State<AttendanceActionButton> { class _AttendanceActionButtonState extends State<AttendanceActionButton> {
final attendanceController = Get.find<AttendanceController>();
late final String uniqueLogKey; late final String uniqueLogKey;
@override @override
@ -189,12 +190,9 @@ class _AttendanceActionButtonState extends State<AttendanceActionButton> {
controller.uploadingStates[uniqueLogKey]?.value = false; controller.uploadingStates[uniqueLogKey]?.value = false;
if (success) { if (selectedProjectId.isNotEmpty) {
await controller.fetchTodaysAttendance(selectedProjectId); await attendanceController.fetchProjectData(selectedProjectId);
await controller.fetchAttendanceLogs(selectedProjectId); attendanceController.update(['attendance_dashboard_controller']);
await controller.fetchRegularizationLogs(selectedProjectId);
await controller.fetchProjectData(selectedProjectId);
controller.update();
} }
} }

View File

@ -33,13 +33,11 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
void initState() { void initState() {
super.initState(); super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
// 🔁 Listen for project changes
ever<String>(projectController.selectedProjectId, (projectId) async { ever<String>(projectController.selectedProjectId, (projectId) async {
if (projectId.isNotEmpty) await _loadData(projectId); if (projectId.isNotEmpty) await _loadData(projectId);
}); });
// 🚀 Load initial data only once the screen is shown WidgetsBinding.instance.addPostFrameCallback((_) {
final projectId = projectController.selectedProjectId.value; final projectId = projectController.selectedProjectId.value;
if (projectId.isNotEmpty) _loadData(projectId); if (projectId.isNotEmpty) _loadData(projectId);
}); });
@ -49,7 +47,7 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
try { try {
attendanceController.selectedTab = 'todaysAttendance'; attendanceController.selectedTab = 'todaysAttendance';
await attendanceController.loadAttendanceData(projectId); await attendanceController.loadAttendanceData(projectId);
attendanceController.update(['attendance_dashboard_controller']); // attendanceController.update(['attendance_dashboard_controller']);
} catch (e) { } catch (e) {
debugPrint("Error loading data: $e"); debugPrint("Error loading data: $e");
} }
@ -375,11 +373,12 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
return MyRefreshIndicator( return MyRefreshIndicator(
onRefresh: _refreshData, onRefresh: _refreshData,
child: SingleChildScrollView( child: Builder(
builder: (context) {
return SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
padding: MySpacing.zero, padding: MySpacing.zero,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
MySpacing.height(flexSpacing), MySpacing.height(flexSpacing),
_buildFilterSearchRow(), _buildFilterSearchRow(),
@ -395,6 +394,8 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
), ),
], ],
), ),
);
},
), ),
); );
}, },

View File

@ -191,11 +191,9 @@ class _PaymentRequestDetailScreenState extends State<PaymentRequestDetailScreen>
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
if (!_checkedPermission) { if (!_checkedPermission && request != null && employeeInfo != null) {
_checkedPermission = true; _checkedPermission = true;
WidgetsBinding.instance.addPostFrameCallback((_) {
_checkPermissionToSubmit(request); _checkPermissionToSubmit(request);
});
} }
const reimbursementStatusId = '61578360-3a49-4c34-8604-7b35a3787b95'; const reimbursementStatusId = '61578360-3a49-4c34-8604-7b35a3787b95';
@ -269,15 +267,20 @@ class _PaymentRequestDetailScreenState extends State<PaymentRequestDetailScreen>
comment: comment.trim(), comment: comment.trim(),
); );
if (!success) {
showAppSnackbar( showAppSnackbar(
title: success ? 'Success' : 'Error', title: 'Error',
message: success message: 'Failed to update status',
? 'Status updated successfully' type: SnackbarType.error,
: 'Failed to update status',
type: success ? SnackbarType.success : SnackbarType.error,
); );
return;
}
if (success) await controller.fetchPaymentRequestDetail(); showAppSnackbar(
title: 'Success',
message: 'Status updated successfully',
type: SnackbarType.success,
);
} }
}, },
child: MyText.bodySmall( child: MyText.bodySmall(