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

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

View File

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

View File

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

View File

@ -33,13 +33,11 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
// 🔁 Listen for project changes
ever<String>(projectController.selectedProjectId, (projectId) async {
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;
if (projectId.isNotEmpty) _loadData(projectId);
});
@ -49,7 +47,7 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
try {
attendanceController.selectedTab = 'todaysAttendance';
await attendanceController.loadAttendanceData(projectId);
attendanceController.update(['attendance_dashboard_controller']);
// attendanceController.update(['attendance_dashboard_controller']);
} catch (e) {
debugPrint("Error loading data: $e");
}
@ -375,26 +373,29 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
return MyRefreshIndicator(
onRefresh: _refreshData,
child: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
padding: MySpacing.zero,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
MySpacing.height(flexSpacing),
_buildFilterSearchRow(),
MyFlex(
child: Builder(
builder: (context) {
return SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
padding: MySpacing.zero,
child: Column(
children: [
MyFlexItem(
sizes: 'lg-12 md-12 sm-12',
child: noProjectSelected
? _buildNoProjectWidget()
: _buildSelectedTabContent(),
MySpacing.height(flexSpacing),
_buildFilterSearchRow(),
MyFlex(
children: [
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();
}
if (!_checkedPermission) {
if (!_checkedPermission && request != null && employeeInfo != null) {
_checkedPermission = true;
WidgetsBinding.instance.addPostFrameCallback((_) {
_checkPermissionToSubmit(request);
});
_checkPermissionToSubmit(request);
}
const reimbursementStatusId = '61578360-3a49-4c34-8604-7b35a3787b95';
@ -269,15 +267,20 @@ class _PaymentRequestDetailScreenState extends State<PaymentRequestDetailScreen>
comment: comment.trim(),
);
if (!success) {
showAppSnackbar(
title: 'Error',
message: 'Failed to update status',
type: SnackbarType.error,
);
return;
}
showAppSnackbar(
title: success ? 'Success' : 'Error',
message: success
? 'Status updated successfully'
: 'Failed to update status',
type: success ? SnackbarType.success : SnackbarType.error,
title: 'Success',
message: 'Status updated successfully',
type: SnackbarType.success,
);
if (success) await controller.fetchPaymentRequestDetail();
}
},
child: MyText.bodySmall(