bug fixed for 1776, 1775, 1736, 1626

This commit is contained in:
Manish 2025-11-26 15:20:20 +05:30
parent 60bc53afef
commit 951dd22ecc
5 changed files with 46 additions and 54 deletions

View File

@ -376,7 +376,7 @@ class AttendanceController extends GetxController {
logSafe( logSafe(
"Project data fetched for project ID: $projectId, tab: $selectedTab"); "Project data fetched for project ID: $projectId, tab: $selectedTab");
update(); update();
} }
// ------------------ UI Interaction ------------------ // ------------------ UI Interaction ------------------

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((_) { ever<String>(projectController.selectedProjectId, (projectId) async {
// 🔁 Listen for project changes if (projectId.isNotEmpty) await _loadData(projectId);
ever<String>(projectController.selectedProjectId, (projectId) async { });
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,26 +373,29 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
return MyRefreshIndicator( return MyRefreshIndicator(
onRefresh: _refreshData, onRefresh: _refreshData,
child: SingleChildScrollView( child: Builder(
physics: const AlwaysScrollableScrollPhysics(), builder: (context) {
padding: MySpacing.zero, return SingleChildScrollView(
child: Column( physics: const AlwaysScrollableScrollPhysics(),
crossAxisAlignment: CrossAxisAlignment.start, padding: MySpacing.zero,
children: [ child: Column(
MySpacing.height(flexSpacing),
_buildFilterSearchRow(),
MyFlex(
children: [ children: [
MyFlexItem( MySpacing.height(flexSpacing),
sizes: 'lg-12 md-12 sm-12', _buildFilterSearchRow(),
child: noProjectSelected MyFlex(
? _buildNoProjectWidget() children: [
: _buildSelectedTabContent(), MyFlexItem(
sizes: 'lg-12 md-12 sm-12',
child: noProjectSelected
? _buildNoProjectWidget()
: _buildSelectedTabContent(),
),
],
), ),
], ],
), ),
], );
), },
), ),
); );
}, },

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(
title: 'Error',
message: 'Failed to update status',
type: SnackbarType.error,
);
return;
}
showAppSnackbar( showAppSnackbar(
title: success ? 'Success' : 'Error', title: 'Success',
message: success message: 'Status updated successfully',
? 'Status updated successfully' type: SnackbarType.success,
: 'Failed to update status',
type: success ? SnackbarType.success : SnackbarType.error,
); );
if (success) await controller.fetchPaymentRequestDetail();
} }
}, },
child: MyText.bodySmall( child: MyText.bodySmall(